I have the following space delimited text file:
ra dec type
197.574288 -0.673779 coadd
201.236362 -1.007902 coadd
191.573312 5.039784 coadd
with "ra" "dec" and "type" as the headers for the file. I want to use an awk command to add a field with constant value "i" before the last field, and a field with constant value "pdr" after the last field so it looks like this:
ra dec i type pdr
197.574288 -0.673779 i coadd pdr
201.236362 -1.007902 i coadd pdr
191.573312 5.039784 i coadd pdr
So far, I've tried many different commands, such as
awk '{printf("i %s pdr2_wide\n",$3,$5)}' psffile.txt > psf50.txt
awk '{printf($1,$2,$3,"i %s pdr2_wide\n",$4,$5)}' psffile.txt > psf50.txt
awk -F '\ ' -v OFS='\ ' '{ $(NF-1) = i; print }' psffile.txt > psf50.txt <br />
EDIT: When I enter the command "awk '{ print $1,$2,"i",$3,"pdr" }' input" it gives me a weirdly formatted output:
ra dec i type pdr
197.574288 -0.673779 i coadd
pdr
201.236362 -1.007902 i coadd
pdr
191.573312 5.039784 i coadd
pdr
Is there a way to fix this?