PDA

View Full Version : extracting a line from a file to a new file and deleting the same from the old file


sunragh
04-12-03, 02:40
dear all,
I want to extract all the lines from a file which is more than 2GB, containing a particular string and these lines are to be appended to a file.
In the next step, the extracted lines from the old file are to be deleted.
Thanks in advance.
sunil

sathyaram_s
04-12-03, 20:46
I do not know how efficient this is for a 2 GB file, but, normally, I would have done the following:

cat <filename> | grep <string> > file1

cat <filename> | grep -v -ffile1

If you want to append the contents of file1 to file2,

cat file2 file1 > file3

Cheers

Sathyaram



Originally posted by sunragh
dear all,
I want to extract all the lines from a file which is more than 2GB, containing a particular string and these lines are to be appended to a file.
In the next step, the extracted lines from the old file are to be deleted.
Thanks in advance.
sunil