14.14 Solaris上如何递归grep https://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 有多种办法 1) 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); \ 2) 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 3) 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); \