bash:-exec在find命令中& [英] bash: -exec in find command and &
本文介绍了bash:-exec在find命令中&的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要跑步:
./my_script.py a_file &
在当前文件夹中所有以 .my_format
结尾的文件上的
...,所以我这样做:
... on all files in the current folder that end with .my_format
, so I do:
find . -type f -name "*.my_format" -exec ./my_script {} & \;
但是它不起作用.我应该如何在 -exec
参数中包含&
?
but it doesn't work. How should I include &
in the -exec
parameter?
推荐答案
尝试一下:
$ find . -type f -name "*.my_format" -exec sh -c './my_script {} &' \;
您的尝试不起作用的最可能原因是因为find使用 exec(3)
系列的标准c库调用之一执行了命令,而该标准c库调用不了解作业控制-&
符号.Shell确实了解在后台运行此命令",因此 -exec sh ...
调用
The mostly likely reason your attempt didn't work is because find executes the command using one of the exec(3)
family of standard c library calls which don't understand job control - the &
symbol. The shell does understand the "run this command in the background" hence the -exec sh ...
invocation
这篇关于bash:-exec在find命令中&的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文