If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > extracting a line from a file to a new file and deleting the same from the old file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-12-03, 01:40
sunragh sunragh is offline
Registered User
 
Join Date: Apr 2003
Posts: 5
Angry extracting a line from a file to a new file and deleting the same from the old file

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
Reply With Quote
  #2 (permalink)  
Old 04-12-03, 19:46
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,543
Re: extracting a line from a file to a new file and deleting the same from the old file

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



Quote:
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On