Frage

Zum Beispiel dieser Zeile nicht:

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

Was ist der richtige Weg, es zu tun?

War es hilfreich?

Lösung

Weil ‚nohup‘ erwartet einen Einzelwortbefehl und dessen Argumente - kein Shell-Schleifenkonstrukt. Sie müssten verwenden:

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

Andere Tipps

Sie können es auf einer Linie, aber man könnte es auch morgen tun wollen.

$ 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 &

Für mich Jonathans Lösung umleiten nicht richtig zu output.txt. Dies funktioniert besser:

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top