grep 在HP-UX下的递归查找

grep 在HP-UX下的递归查找

Linux: man grep 可以看到 -r 选项
 -R, -r, --recursive
              Read all files under each directory, recursively; this is equivalent to the -d recurse option.
即:-r 选项可以查找指定目录下每个子目录下的所有文件
eg:
grep -r "28281" .
//查询当前路径下文件及各个子目录下的所有文件中的包含28281的文件;

但是在HP-UX下不支持-r这一选项,怎么办呢?
查询man find,可以看到:
 -exec cmd                True if the executed cmd returns a zero value
                               as exit status.  The end of cmd must be
                               punctuated by a semicolon (;) or a plus sign
                               (+) (semicolon and plus are special to the
                               shell and must be escaped).  When + is used,
                               cmd aggregates a set of path names and
                               executes on the set.  Any command arguments
                               between the first occurrence of {} and + are
                               ignored.  The reason for preferring + to a ;
                               is vastly improved performance.  Any command
                               argument {} is replaced by the current path
                               name.  cmd may contain supplementary code set
                               characters.
                               // 命令必须以分号;或者加号+结束(分号和加号在shell
                               中有特殊意义,必须用转义)。当使用+时,命令会聚集成
                               路径名的一个集合,{}和+之间命令参数会被忽略。
                               优先使用+,是因为+的性能更好。
                               命令中的参数{}将会被当前的路径名说取代。

比如:
find . -type f -exec grep "IFPC" {} \+
//在当前路进行及其子文件夹中的文件中查找包含IFPC字符串的文件;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值