Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Posts
    5

    Angry Unanswered: 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

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    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



    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •