find 명령(grep 사용)의 출력을 로그 파일로 리디렉션하려면 어떻게 해야 합니까?

find 명령(grep 사용)의 출력을 로그 파일로 리디렉션하려면 어떻게 해야 합니까?

"검색 문자열" 패턴을 포함하는 모든 파일을 검색하는 코드를 고려해보세요.

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

관련 정보