I have a file in the below given format. First two lines are header and Trailer. Rest all are transaction Lines. I have to delete all other lines except first line (Header) and lines which contains 5000 in 1st column and 0 in 5th column.
Can anyone please kindly provide me with the script code. Thanks in Advance.
---------- Post updated at 12:37 ---------- Previous update was at 12:36 ----------
If your header line will not always contain the literal word Header, then the previous solution will not meet your requirement and you will want to check this sed approach:
sed q file > tmpfile
sed '/^5000.* 0$/!d' file >> tmpfile
mv tmpfile file
Thank you very much for the replies. I request few changes. Please click the below link to see the sample file which needs to be modified using the script.
Apologies. there is no 4 and 8. its mistakenly typed. My requirement is to Append H and T before line 1 and 2 and remove all other lines other than one which has 5000 and 0 in 1st and 5th column.
Thanks,
Phani Akella.
---------- Post updated 06-12-10 at 10:27 AM ---------- Previous update was 06-11-10 at 12:26 PM ----------
Hi rdcwayx,
I have modified your code and it is working fine now. Thank you very much. I have changed NF with $5.