使用在查找-exec别名 [英] Using an alias in find -exec
问题描述
我在bash,我不想输入所有的时间很长的命令,所以我把一个别名在我的.profile
I have a very long command in bash, which I do not want to type all the time, so I put an alias in my .profile
alias foo='...'
现在我想用找到-exec来执行此别名
Now I want to execute this alias using find -exec
find . -exec foo '{}' \;
但发现无法找到foo的:
but find cannot find foo:
查找:富:没有这样的文件或目录
find: foo: No such file or directory
是否有可能在查找使用的别名?
Is it possible to use an alias in find?
推荐答案
不,发现不知道你的别名任何东西。别名不喜欢,他们不通过子进程继承环境变量。
Nope, find doesn't know anything about your aliases. Aliases are not like environment variables in that they aren't "inherited" by child processes.
您可以创建一个相同的命令shell脚本,设置+ X的权限,并在您的路径。这将找到工作。
You can create a shell script with the same commands, set +x permissions and have it in your path. This will work with find.
这篇关于使用在查找-exec别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!