posted 11 years ago
I have files that need to be processed by the awk script below, but the outcome is such that the awk script:
a. places a pipe | at the beginning of the line when I do not expect it
b. does not print the first character of the first field
Any help understanding why a & b happen would be very much appreciated.
My input lines are similar to this one:
7035ABC071222|AB4801|123|E|I|1|SER|1|BAKBAA1|20990220||MONSTER INC||PP02X||||||008354||0001||N|MPC|0|
7035ABC071222|AB4801|123|P|EP|6|SER|1|BA5JAA1|20991228||MONSTER INC||LATITUDE E3810|20110427|||||008523||BLDG 15||Y|MPC|0|
The code is:
The output looks like :
THIS IS THE FIRST 7035ABC071222
|035ABC071222|AB4801|123|E|I|1|SER|1|BAKBAA1|20990220||MONSTER INC||PP02X||||||008354||0001||N|MPC|0|
THIS IS THE FIRST 7035ABC071222
|035ABC071222|AB4801|123|P|EP|6|SER|1|BA5JAA1|20991228||MONSTER INC||LATITUDE E3810|20110427|||||008523||BLDG 15||Y|MPC|0|
WHy would a[1] print "7035ABC071222", but a[x] prints "|035ABC071222" ?
Thank you in advance, and yes, I am not very familiar with awk. If fact, if I do not figure this out I can write it in something else ...