Can someone help me to do this with awk or sed? I have a file with multiple lines, each line has many fields separated with a tab. I would like to add one more field holding 'na' in between the first and second fields.
guys in the out below it is between 2nd and 3rd not 1st and 2nd
1, field1 field2 field3 ...
2, field1 field2 field3 field4 ...
.
.
output:
1, field1 na field2 field3 ...
2, field1 na field2 field3 field4 ...
so my code is true.
awk -F"\t" '(NF!=0){ $2=$2"\t""na" }1 ' OFS="\t" input.txt
I believe '1, field' is field 1 with the embedded space.
If the OP used the code tags when posting code/data samples, we could all be sure.
It's for the OP to shed a light on the issue.