find
명령에서 제외 경로를 지정하기 위해 변수를 사용하려고합니다.변수를 사용하여`find`에서 제외시킬 경로를 어떻게 지정합니까?
x="*test/.util/*"
y="*test/sh/*"
find test -type f -name "*.sh" -not -path "$x" -not -path "$y"
하지만 같이 변수로 -not -path
를 이동하고 싶습니다 :
이 조각 작품 나는 또한 변수의 경로에 따옴표를 추가하는 시도
x="-not -path *test/.util/*"
y="-not -path *test/sh/*"
# error: find: -not -path *test/.util/*: unknown primary or operator
find test -type f -name "*.sh" "$x" "$y"
# Tried removing quotes
# error: find: test/.util/foo.sh: unknown primary or operator
find test -type f -name "*.sh" $x $y
하지만, 그 결과 경로 필터링이 발생하지 않습니다.
# no syntax error but does not exclude the paths
x="-not -path '*test/.util/*'"
y="-not -path '*test/sh/*'"
저는 OSX Mavericks를 사용하고 있습니다. GNU bash 버전 3.2.51 (1) -release (x86_64-apple-darwin13).
내가 뭘 잘못하고 있니? 감사합니다
@ chepner의 대답은 전적으로 정확하고 정확한 것입니다. 또한 BashFAQ # 50 : http://mywiki.wooledge.org/BashFAQ/050 –