Find the answer to your Linux question:
Results 1 to 3 of 3
I have a file that in which email messages are stored in and every email is separated by by a ^Z character (Control-Z). I need to delete all emails after ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    1

    Modify Text in a file

    I have a file that in which email messages are stored in and every email is separated by by a ^Z character (Control-Z).

    I need to delete all emails after the 65,00th one.

    Any suggests on accomplishing this?

  2. #2
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    You can do this with "awk". Set the RS to ^Z and throw away all the records after the limit.

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Posts
    10
    to preserve your emails file, make sure you add a ctrl+z after writing each email. one possible way to accomplish that would be:

    #process.awk
    BEGIN {
    RS="^Z"
    }
    {
    if ( NR <= 65 ) {
    printf("%s",$0);
    printf("%s","^Z")
    }
    }

    and then you call this script from the command line:
    awk -f process.awk emailsfile1 > emailsfile2

    of course you can redirect the output to emailsfile1 itself, but you should see first if this does what you really want

Posting Permissions

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