네, find ./work -print0 | xargs -0 rm뭔가를 실행합니다 rm ./work/a "work/b c" .... 로 확인할 수 있으며 echo, find ./work -print0 | xargs -0 echo rm실행될 명령을 인쇄합니다 (공백이 echo표시되지는 않지만 적절하게 이스케이프 되지는 않습니다).
얻으려면 xargs중간에 이름을 넣어, 당신은 추가해야 할 -I[string]경우, [string]당신은 당신이 사용하는 거라고이 경우, 인수로 대체 할 것입니다 -I{}예를 들어, <strings.txt xargs -I{} grep {} directory/*.
실제로 사용하고 싶은 것은 grep -F -f strings.txt:
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by
newlines, any of which is to be matched. (-F is specified by
POSIX.)
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file
contains zero patterns, and therefore matches nothing. (-f is
specified by POSIX.)
따라서 grep -Ff strings.txt subdirectory/*모든 문자열을 strings.txt리터럴로 찾을 -F수 있습니다 . 옵션을 삭제 하면 파일에서 정규식을 사용할 수 있습니다. 실제로 사용할 수도 grep -F "$(<strings.txt)" directory/*있습니다. 연습하고 싶다면 find요약의 마지막 두 예제를 사용할 수 있습니다. 첫 번째 수준이 아닌 재귀 검색을 수행하려는 경우 요약에도 몇 가지 옵션이 있습니다.
요약:
# grep for each string individually.
<strings.txt xargs -I{} grep {} directory/*
# grep once for everything
grep -Ff strings.txt subdirectory/*
grep -F "$(<strings.txt)" directory/*
# Same, using file
find subdirectory -maxdepth 1 -type f -exec grep -Ff strings.txt {} +
find subdirectory -maxdepth 1 -type f -print0 | xargs -0 grep -Ff strings.txt
# Recursively
grep -rFf strings.txt subdirectory
find subdirectory -type f -exec grep -Ff strings.txt {} +
find subdirectory -type f -print0 | xargs -0 grep -Ff strings.txt
-l실제 줄을 볼 필요가없는 경우 옵션 을 사용하여 일치하는 각 파일의 이름 만 가져 오십시오.
-l, --files-with-matches
Suppress normal output; instead print the name of each input
file from which output would normally have been printed. The
scanning will stop on the first match. (-l is specified by
POSIX.)