Skip to content

Latest commit

 

History

History
44 lines (23 loc) · 924 Bytes

200011200000.txt.md

File metadata and controls

44 lines (23 loc) · 924 Bytes

14.14 Solaris上如何递归grep

http://scz.617.cn/unix/200011200000.txt

Q:

在Solaris上执行

find /usr/include -type f -name "*.h" -exec grep -n CE_NOTE {} ;

得到

560: cmn_err(CE_NOTE, xyz); \

可我想知道包含关键字的文件是哪个。

如果是Linux,可以这样:

find /usr/include -type f -name "*.h" -exec grep -Hn CE_NOTE {} ;

但Solaris的grep不支持-H。

A: Argoth 2000-11-20

有多种办法

find /usr/include -type f -name "*.h" | xargs grep -n CE_NOTE

/usr/include/sys/fs/udf_inode.h:560: cmn_err(CE_NOTE, xyz); \

find /usr/include -type f -name "*.h" -exec grep -n CE_NOTE {} ; -print

560: cmn_err(CE_NOTE, xyz);
/usr/include/sys/fs/udf_inode.h

find /usr/include -type f -name "*.h" -exec grep -n CE_NOTE {} /dev/null ;

/usr/include/sys/fs/udf_inode.h:560: cmn_err(CE_NOTE, xyz); \