
「検索文字列」パターンを含むすべてのファイルを検索するコードを検討してください。
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$
Solaris のマニュアルページから探す:
-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.
したがって、セミコロンをエスケープすることが必須のようです。この問題を解決する他の方法はありますか?
答え1
を削除しています\;
。以下を実行してください。
find . -type f -exec grep -il "search string" {} \; > log.txt