Ken*_*war 10 grep solaris find io-redirection
考虑搜索包含模式“搜索字符串”的所有文件的代码:
bash-3.2$ # The below find works fine..
bash-3.2$ find . -type f -exec grep -il "search string" {} \;
bash-3.2$ # But I am unable to redirect output to a log file..
bash-3.2$ find . -type f -exec grep -il "search string" {} \ > log.txt
find: incomplete statement
bash-3.2$
Run Code Online (Sandbox Code Playgroud)
从 Solaris 的手册页中找到:
Run Code Online (Sandbox Code Playgroud)-exec command True if the executed command returns a zero value as exit status. The end of command must be punctuated by an escaped semicolon. A command argument {} is replaced by the current path name.
因此,转义分号似乎是强制性的。有没有其他方法可以解决这个问题?
ter*_*don 12
您正在删除\;. 只需这样做:
find . -type f -exec grep -il "search string" {} \; > log.txt
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
68226 次 |
| 最近记录: |