Consider this awk script to print column #2 of every line:
awk '{print $2}' a.txt
. $2 is not a shell variable, yet when I attempt to submit this code to qsub, $2 is interpreted as such. I.e.
qsub awk '{print $2}' a.txt
results in qsub executing the command
awk '{print }' a.txt
To be clear, I'm not trying to use a shell variable in an awk script; therefore How do I use shell variables in an awk script? is not applicable.
I tried suggestions in Using awk with qsub and issues with quotations, including \$2
and
qsub -- awk '{print $2}' a.txt
.
Neither works.
I can certainly put awk in a script and call qsub that way, i.e., qsub awkscript.sh
. However, if there's a way to use qsub+awk from the command line, I'd like to learn how.