Remove the footer from a flat file by searching a pattern

Hi,
I have more than 30,000 records in a flat file. I want to remove footer from the file by searching a string pattern for the footer.
Example.... let the flat file test.dat contains below records.

record1
record2
record3
..
..
..
record31000
Total records 31000

I want to remove the last line ("Total records 31000") from the file by searching for the string "Total records". I want to modify the input file by removing the line, i don't want to use a separate file as output file due to the large size of the input file. please suggest me.

Thanks in advance.

Try this...

sed -i '/Total records/ d' input_file

--ahamed

Thanks Ahamed.
But I think your code needs an output file for writing the output. I need to modify the input file as the size of the input file is large.

No, the "-i" option will modify the original file itself!

--ahamed

using awk ..

$ awk '!/Total records/' infile

Hi ahamed,
I think the option "-i" is shell specific. This command is working fine in bash, but not working in ksh. Please suggest me if you have any suggestions(code). thanks...

Hi jayan_jay,
This command is fine but needs an output file for writing the output. I need to modify the input file as the size of the input file is large. Please suggest me if you have any idea for this. Thanks...

which OS are you using? If Solaris, try using /usr/xpg4/bin/sed

--ahamed