Current field length : 361 bytes
To the record , i am appending the filename and hard-coding batchid.
The record length has increased from 361 to 400 and since i will continue to get both files ie 361 and 400 length sizes
i want to write a program that can handle both of them.
To the new files i want to cut the string from 362 to 400 and append after the batch id and filename as shown below
Both Input and Output are fixed length files
Output File Layout
------------------
'1 - 361''filename''batch_id'
'1- 361''filename''batch_id''362-400'
Existing code
-------------
for file in /export/home/input/temp/abc[0-9][0-9].dat;do
nawk '/............B[HT]0/{print "HDR/TRLR " ctr++ " : " $0 ;next }
/............H10/{print $0 |" sed s/$/'`basename $file`BATCHID'/ >>/output/outfile.dat " } ' $file
done
New Code
--------
I am not sure if this logic is correct or i might have complicated it.Please suggest
for file in /export/home/input/temp/abc[0-9][0-9].dat;do
nawk '/............B[HT]0/{print "HDR/TRLR " ctr++ " : " $0 ;next }
/............H10/{bl = substr($0,1,361);el = substr($0,362); print bl '`basename $file`BATCHID' el >>/output/outfile.dat " } ' $file
Its treating bl '`basename $file`BATCHID' el >>/output/outfile.dat " as a string rather than as a variable.
Can we run a Unix command in awk program? coz replacing SED here is giving me all kinds of problems.
Please help