gpt4 book ai didi

shell - 路径中有FIFO时如何递归grep

转载 作者:行者123 更新时间:2023-12-04 17:54:34 25 4
gpt4 key购买 nike

我想做一个递归的grep。所以通常我会做以下事情:

grep pattern -r /some/path

通常这会起作用。但是,当路径中存在 FIFO 文件时,grep 将卡在那里。
johnson@ISD32_54_sles10:~/tmp$ ls -l 1
prw-r--r-- 1 neoli users 0 2012-05-16 17:24 1

然后我调用 strace 命令来确定问题,我得到了这个。
...
stat64("./1", {st_mode=S_IFIFO|0644, st_size=0, ...}) = 0
open("./1", O_RDONLY|O_LARGEFILE) = 3
read(3, <unfinished ...>

所以我的问题是当路径中有 FIFO 时如何进行递归 grep? grep 是否有一个命令行选项,它会告诉 grep 在指定时忽略 FIFO?

感谢您的帮助。

最佳答案

来自 man grep (GNU)

-D ACTION, --devices=ACTION

If an input file is a device, FIFO or socket, use ACTION to process it.
By default, ACTION is read, which means that devices are read just as if
they were ordinary files. If ACTION is skip, devices are silently skipped.

关于shell - 路径中有FIFO时如何递归grep,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10615803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com