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 ...
- 10-22-2008 #1Just 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?
- 10-23-2008 #2Linux 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.
- 10-27-2008 #3Just 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


Reply With Quote