为什么我不能将 Unix Nohup 与 Bash For-loop 一起使用? [英] Why can't I use Unix Nohup with Bash For-loop?

查看:31
本文介绍了为什么我不能将 Unix Nohup 与 Bash For-loop 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如此行失败:

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

正确的做法是什么?

推荐答案

因为 'nohup' 需要单字命令及其参数 - 而不是 shell 循环结构.你必须使用:

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

这篇关于为什么我不能将 Unix Nohup 与 Bash For-loop 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆