我如何使用管道在EXEC参数的find命令? [英] How do I use a pipe in the exec parameter for a find command?
本文介绍了我如何使用管道在EXEC参数的find命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图构建一个find命令来处理一堆文件中使用两种不同的可执行文件的目录。不幸的是, -exec
上查找不允许使用的管道,甚至 \\ |
因为shell间$ P $点这个角色第一次。
下面是具体是什么我想要做的(这并不工作,因为管端find命令):
查找/路径/要/ JPG文件型的F -exec jhead的-v {} | grep的123 \\; -打印
解决方案
试试这个
查找/路径/要/ JPG文件型的F -exec SH -c'jhead的-v {} | 123的grep'\\; -打印
另外,您可以尝试嵌入一个sh脚本里面的exec语句,然后执行:
找到-exec some_script {} \\;
I'm trying to construct a find command to process a bunch of files in a directory using two different executables. Unfortunately, -exec
on find doesn't allow to use pipe or even \|
because the shell interprets that character first.
Here is specifically what I'm trying to do (which doesn't work because pipe ends the find command):
find /path/to/jpgs -type f -exec jhead -v {} | grep 123 \; -print
解决方案
Try this
find /path/to/jpgs -type f -exec sh -c 'jhead -v {} | grep 123' \; -print
Alternatively you could try to embed your exec statement inside a sh script and then do:
find -exec some_script {} \;
这篇关于我如何使用管道在EXEC参数的find命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文