GNU Parallelによって実行されているスクリプトに、空白やその他の文字を含むテキストを渡す必要があります。
非常に簡単な例を次に示します。
$ seq 1 3 | parallel echo "Quoted ' (text)"
上記の例はこれを出力します:
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
ただし、これを行うと、すべてが機能します。
seq 1 3 | parallel echo "\"Quoted ' (text)\""
私はたまたまこれをPythonスクリプトから実行しているので、引数を渡す前に、次のようにスクリプトで引数を二重引用符で囲んでいます。
args = ["Some arg", "Another arg", "etc."]
args = ' '.join(pipes.quote(pipes.quote(arg)) for arg in args)
しかし、それはクリーンな解決策のようには思えません。
GNU Parallelに引数を渡すためのより良い方法を知っている人はいますか?
ありがとう!