2

Problems with single quotes in a bash script

I have seen this post but my problem is more complicated and simply replacing single quotes with double quotes won't work. I need to run a R CMD BATCH command with single quotes and double quotes within the single quotes, something like this

echo 'R CMD BATCH --no-save '--args "xxx.txt"' xxx.r' | qsub -cwd &

What should I do?

4

2 回答 2

4

使用here-document,而不是管道,这样就不需要外层的引号。

qsub -cwd <<'EOF' &
R CMD BATCH --no-save '--args "xxx.txt"' xxx.r
EOF
于 2015-12-23T15:31:26.143 回答
2

为此,我使用所谓的5 引号模式

 'this '"'"' that'

=>this ' that

 "this "'"'" that"

=>this " that

于 2015-12-23T15:09:30.573 回答