로부터 에 대한 맨 페이지 find명령
:
-exec command ;
Execute command; true if 0 status is returned. All following arguments to find are taken to be arguments to
the command until an argument consisting of `;' is encountered. The string `{}' is replaced by the current
file name being processed everywhere it occurs in the arguments to the command, not just in arguments where it
is alone, as in some versions of find. Both of these constructions might need to be escaped (with a `\') or
quoted to protect them from expansion by the shell.
설명은 다음과 같습니다.
{}"의 출력"을 의미합니다 find. "무엇이든 find발견". find찾고있는 파일의 경로를 반환합니다. 따라서 {}그것을 대체하십시오. find명령이 찾는 각 파일의 자리 표시 자입니다 ( 여기 에서 가져옴 ).
이 \;부분은 기본적으로 find"알겠습니다. 실행하고 싶은 명령으로 끝났습니다"라고 말합니다.
예:
내가 .txt파일로 가득 찬 디렉토리에 있다고 가정 해 봅시다 . 그런 다음 실행합니다.
find . -name '*.txt' -exec cat {} \;
첫 번째 부분 find . -name *.txt은 .txt파일 목록을 반환 합니다. 두 번째 부분은, -exec cat {} \;실행]됩니다 cat에 의해 발견 된 모든 파일에 대한 명령을 find하므로, cat file1.txt, cat file2.txt, 등.
-name *중복됩니다.