可以find命令的" EXEC"功能在后台启动的程序? [英] Can the find command's "exec" feature start a program in the background?

查看:259
本文介绍了可以find命令的" EXEC"功能在后台启动的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样做是这样的:

find . -iname "*Advanced*Linux*Program*" -exec kpdf {} & \;

可能吗?可用一些其他类似的方法是什么?

Possible? Some other comparable method available?

推荐答案

首先,你输入它不会工作,因为shell会间preT为

Firstly, it won't work as you've typed, because the shell will interpret it as

find . -iname "*Advanced*Linux*Program*" -exec kpdf {} &
\;

这是一个无效的发现在后台运行,其次是不存在的命令。

which is an invalid find run in the background, followed by a command that doesn't exist.

即使逃脱这是行不通的,因为找到-exec 实际上 EXEC S中的参数列表中给出,而不是它给予一个shell(这是实际处理&安培; 为一个后台)。

Even escaping it doesn't work, since find -exec actually execs the argument list given, instead of giving it to a shell (which is what actually handles & for backgrounding).

一旦你知道的的问题,你所要做的就是启动一个shell给这些命令:

Once you know that that's the problem, all you have to do is start a shell to give these commands to:

find . -iname "*Advanced*Linux*Program*" -exec sh -c '"$0" "$@" &' kpdf {} \;



在另一方面,给你想要做什么,我会建议之一

On the other hand, given what you're trying to do, I would suggest one of

find ... -exec kfmclient exec {} \;  # KDE
find ... -exec gnome-open {} \;      # Gnome
find ... -exec xdg-open {} \;        # any modern desktop

将打开默认程序的文件由您的桌面环境有关。

which will open the file in the default program as associated by your desktop environment.

这篇关于可以find命令的" EXEC"功能在后台启动的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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