パターン「検索文字列」を含むすべてのファイルを検索するコードについて考えてみます。
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.
したがって、エスケープされたセミコロンは必須のようです。これについて別の方法はありますか?
を削除してい\;
ます。これを行うだけです:
find . -type f -exec grep -il "search string" {} \; > log.txt
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加