![find -prune: -print0이 검색 결과에 영향을 미치는 이유는 무엇입니까? [복사]](https://linux55.com/image/228638/find%20-prune%3A%20-print0%EC%9D%B4%20%EA%B2%80%EC%83%89%20%EA%B2%B0%EA%B3%BC%EC%97%90%20%EC%98%81%ED%96%A5%EC%9D%84%20%EB%AF%B8%EC%B9%98%EB%8A%94%20%EC%9D%B4%EC%9C%A0%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%20%5B%EB%B3%B5%EC%82%AC%5D.png)
상상하다:
$ tree .
.
├── x1.txt
├── x2.txt
└── x3.txt
0 directories, 3 files
$ find . -name "x1.txt" -prune -o -name "*.txt"
./x1.txt
./x2.txt
./x3.txt
$ find . -name "x1.txt" -prune -o -name "*.txt" -print0
./x2.txt./x3.txt
-print0
여기서는 이것이 검색 결과에 영향을 미친다는 것을 알 수 있습니다 . 혼란스러워하세요.
왜 인쇄 되지 -print0
않습니까 ?find ...
x1.txt
왜 인쇄 -print0
되지 않습니까 ?find ...
x1.txt
답변1
find
-prune
( 또는 이외의 -quit
작업이 지정되지 않은 경우 사용됨 ) 의 기본 작업 은 입니다 -print
.
find . -name "x1.txt" -prune -o -name "*.txt"
-print
모든 경우에 암시적:
find . -name "x1.txt" -prune -print -o -name "*.txt" -print
혹은 더 정확하게는,
find . \( -name "x1.txt" -prune -o -name "*.txt" \) -print
추가하면 -print0
기본값이 제거되므로
find . -name "x1.txt" -prune -o -name "*.txt" -print0
"이름이 일치하면 x1.txt
잘라내고, 그렇지 않으면 일치하면 *.txt
null 종결자를 사용하여 인쇄합니다"를 의미합니다.