空字符破坏 find -exec 中的管道
我试图找到给定目录下的每个 Perl 脚本,并运行我在它们上编写的脚本。我想出了类似
find . -type f -exec file {} \; | grep perl | awk -F':' '{print $1}' | myscript
我担心某个文件名中存在“:”的东西,所以尽管我会使用 file
的 --print0
选项给我类似的东西
find . -type f -exec file --print0 {} \; | grep perl | awk -F'\0' '{print $1}' | myscript
它不起作用。我收到了一堆 find: `file' returned by signal 13
错误,据我所知,这表明管道损坏了。有没有:
I'm trying to find every Perl script under a given directory, and run a script I wrote on them. I came up with something like
find . -type f -exec file {} \; | grep perl | awk -F':' '{print $1}' | myscript
I'm concerned about there beiong a ':' in a filename somewhere, so though I'd use file
's --print0
option to give me something like
find . -type f -exec file --print0 {} \; | grep perl | awk -F'\0' '{print $1}' | myscript
It doesn't work. I get a bunch of find: `file' terminated by signal 13
errors instead, which I understand to be indicating a broken pipe. Is there either:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
毕竟这真的很简单:
It is really simple, after all: