I'm trying to run a script which will submit a bunch of awk commands along the following lines:
qsub -l h_vmem=32G -l h_rt=04:00:00 "awk '{if (last != $10) close(last); print >> "/directory/working/"$10 ".txt"; last = $10}' /directory/working/working_file.txt"
The awk command itself works fine when run in an interactive session, the issue is that when combined with qsub
it returns something along the lines of:
error opening awk '{if (last != 0) close(last); print >> '/directory/working: No such file or directory
Initially I thought this would be solved by putting the entire awk command in double quotation marks (as I've done above) but this also returned the same error. My understanding of this is that it isn't working because of the extra double quotation marks inside the awk command. But as far as I'm aware, I need those extra double quotation marks inside the command.
I tried changing it so that every quotation inside the first set of double quotes were just single quotes, but that didn't work. I then tried:
qsub -l h_vmem=32G -l h_rt=04:00:00 "$(awk ...)"
But that did not seem to work either (or at least after submitting it, it didn't return an error but didn't actually seem to submit.
Is there any way around this/any solutions with all the various quotations?