I am using this awk command to extract three rows from a text file.
awk 'BEGIN {FS="\t";OFS=","}; {print $1,$3,$10}' $FILENAME > $OUTPUT
I wish to specify the column numbers as a variable separately so it will be easier to modify in the future like this:
COLUMNS=$1,$3,$10
awk 'BEGIN {FS="\t";OFS=","}; {print $COLUMNS}' $FILENAME > $OUTPUT
However it pulls all columns into the output, not only the 3 I specified. How do I do this properly?
echo $COLUMNSand start getting enlightened. ;-)