bsub は while ループでは使用されません。

bsub は while ループでは使用されません。

次のコマンドを実行しようとしましたが、エラーが発生しました。

syntax error near unexpected token `do'

注文する:

bsub -q XXX -P YYY -J ZZZ -R "rusage[mem=10000,scr=5000]" -R "span[hosts=1]" -n 2 -o lsf.out -e lsf.er  while read  -r line; dofilename=$(echo $line | awk '{print $1}'); content=$(echo $line | cut -d ' ' -f 2-); echo "$content" | tr ' ' '\n' > "$filename.txt"; done < input.txt

次のコマンドが正常に実行されます。

while read  -r line; dofilename=$(echo $line | awk '{print $1}'); content=$(echo $line | cut -d ' ' -f 2-); echo "$content" | tr ' ' '\n' > "$filename.txt"; done < input.txt

ただし、同じコマンドにオプションを追加するとbsub失敗します。

ベストアンサー1

前に区切り文字が必要ですwhile

busb ... -o lsf.out -e lsf.er  while read ...

しなければならない

busb ... -o lsf.out -e lsf.er ; while read ...

そしてdofilename=...実際にそうしなければなりませんdo filename=...

==

bashを使用すると確かに効果があります。

あなたのbsubコマンドやinput.txtファイルがないので...

alias bsub=true
cat >input.txt
foo
bar
baz
^D

それから

$ bsub -q XXX -P YYY -J ZZZ -R "rusage[mem=10000,scr=5000]" -R "span[hosts=1]" -n 2 -o lsf.out -e lsf.er ; while read  -r line; do filename=$(echo $line | awk '{print $1}'); content=$(echo $line | cut -d ' ' -f 2-); echo "$content" | tr ' ' '\n' > "$filename.txt"; done < input.txt
$

実行成功。

セミコロンと「do filename」スペースの両方が必要です。

おすすめ記事