Can someone please help in below requirement.
My requirement is to add date before to first column,some text before 1st,2nd coulmns and insert a new column in between 2 and 3 columns.
input file.
aa 123 dddd
aa 667 kdkdk
ddj 738 kkkk
aa 123 dddd
aa 667 kdkdk
aa 123 dddd
aa 667 kdkdk
You're not too far off. awk can't handle shell variables immediately. Did you consider awk 's -v option to convey (shell variables') values into awk variables? Then, print the awk variable holding the date value just in front of the other fields.
Your DATE is not correct, the time is missing. The new column can be just written, as you wrote any other text in your print. DATE can be handed over to awk with -v: