我想做一个递归的grep.通常我会做以下事情:
grep pattern -r /some/path
Run Code Online (Sandbox Code Playgroud)
通常这会起作用.但是,当FIFO文件驻留在路径中时,grep会卡在那里.
johnson@ISD32_54_sles10:~/tmp$ ls -l 1
prw-r--r-- 1 neoli users 0 2012-05-16 17:24 1
Run Code Online (Sandbox Code Playgroud)
然后我调用strace命令来识别问题,我得到了这个.
...
stat64("./1", {st_mode=S_IFIFO|0644, st_size=0, ...}) = 0
open("./1", O_RDONLY|O_LARGEFILE) = 3
read(3, <unfinished ...>
Run Code Online (Sandbox Code Playgroud)
所以我的问题是当路径中有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.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
545 次 |
| 最近记录: |