Hi All, I would like to have a windows batch script which can run on XP and NT machines and can perform...
Requirements:
1. Batch program should modify the file placed in D:/Test/ folder.
2. First and Second lines with 0000 are Header and Trailer. Batch script should prefix H before 1st 0000 and T before second 0000.3. Script should remove all lines other than which has value 5000 in 1st column and 0 in 5th column.
File Snippet Before Execution of Script:0000 00000 00000008499 0000999 0
0000 00000 00000008499 0000999 0
1000 00000 00000008499 0000999 0
9999 00000 00000008499 0000999 0
5000 09999 00000008499 0000999 0
5000 09999 00000008499 0000999 7
5000 09999 00000008499 0000999 0
5000 09999 00000008499 0000999 0
5000 09999 00000008499 0000999 7
4300 09999 00000008499 0000999 0
6000 09999 00000008499 0000999 0
1000 09999 00000008499 0000999 7File Snippet After Execution of Script:-
H0000 00000 00000008499 0000999 0
T0000 00000 00000008499 0000999 0
5000 09999 00000008499 0000999 0
5000 09999 00000008499 0000999 0
5000 09999 00000008499 0000999 0Thanks,
Phani Akella
here's a one liner for you C:\test>sed -n "1 s/^/H/p;2 s/^/T/p;/^5000.*0$/p" file H0000 00000 00000008499 0000999 0 T0000 00000 00000008499 0000999 0 5000 09999 00000008499 0000999 0 5000 09999 00000008499 0000999 0 5000 09999 00000008499 0000999 0you can download sed here
Hi, My file is Tab delimited. And first 2 lines Header are Trailer are of 14 fields and where as Transaction records (are around 56 fields). Sed command has to remove all lines other that which has value 5000 in 1st column and 0 in the 5th column.
Instead of a command. Can i make this into a batch file and perform all the changes on a click on the batch with out changing the file name?
Thanks,
Phani Akella
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |