为什么我不能使用的Unix NOHUP使用bash for循环? [英] Why can't I use Unix Nohup with Bash For-loop?

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

问题描述

例如此行失败:

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

推荐答案

由于'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循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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