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

标签 shell grep fifo

我想做一个递归的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/

相关文章:

以科学记数法返回的 Bash 数字序列?

bash - sed/awk : Extract pattern from text stream

linux - 使用 grep 在同一文本行中搜索多个模式[由换行符分隔]

sql查询fifo库存

linux - 使用一个 bash 脚本在 diff 目录中执行多个 bash 脚本

bash - 我怎样才能正确地将多个 bash 脚本源到彼此?

java - 如何终止从 shell 脚本运行的 JVM?

html - 如何在bash中仅使用grep提取html标签

C语言内存管理与字符串段和fifo

c# - 缓存先前搜索的策略 (ASP.NET)