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字符串的文件;
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字符串的文件;