문제

For example this line fails:

$ nohup for i in mydir/*.fasta; do ./myscript.sh "$i"; done > output.txt&
-bash: syntax error near unexpected token `do

What's the right way to do it?

도움이 되었습니까?

해결책

Because 'nohup' expects a single-word command and its arguments - not a shell loop construct. You'd have to use:

nohup sh -c 'for i in mydir/*.fasta; do ./myscript.sh "$i"; done >output.txt' &

다른 팁

You can do it on one line, but you might want to do it tomorrow too.

$ cat loopy.sh 
#!/bin/sh
# a line of text describing what this task does
for i in mydir/*.fast ; do
    ./myscript.sh "$i"
done > output.txt
$ chmod +x loopy.sh
$ nohup loopy.sh &

For me, Jonathan's solution does not redirect correctly to output.txt. This one works better:

nohup bash -c 'for i in mydir/*.fasta; do ./myscript.sh "$i"; done' > output.txt &

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top