I have a file named file1.txt where below data is there
APPLICATION ODATE IF_EXECUTING APPLICATION_STATUS
Job1 20200731 Post NOTOK
Job2 20200731 Post NOTOK
Job3 20200731 Post NOTOK
JOb3 20200731 Post NOTOK
``````````````````````````````````````````````````````
Adding one new column using below command
awk -v column=4 -v value=”four” ‘BEGIN {FS = OFS = “ttt”;}{for ( i = NF + 1; i > column; i– ) {$i = $(i-1);}$i = value;print $0;}’ file1.txt
Output
`````````````````````````````````````````````````````````````````````````````````````````
APPLICATION ODATE IF_EXECUTING APPLICATION_STATUS four
Job1 20200731 Post NOTOK four
JOb2 20200731 Post NOTOK four
Job3 20200731 Post NOTOK four
JOb4 20200731 Post NOTOK four
`````````````````````````````````````````````````````````````````````````````````````````````
Here adding three "t" character. First line "four" should be spaced with APPLICATION_STATUS with just one t and first line "four" should be replaced with "CYCLE_NUMER"
Desired output
````````````````````````````````````````````````````````````````````````````````
APPLICATION ODATE IF_EXECUTING APPLICATION_STATUS CYCLE_NUMBER
Job1 20200731 Post NOTOK four
JOb2 20200731 Post NOTOK four
Job3 20200731 Post NOTOK four
JOb4 20200731 Post NOTOK four
`````````````````````````````````````````````````````````````````````````````
Go to Source
Author: Sourin Biswas