2014-07-18 7 views
3

나는 c.js디렉토리에서 파일을 무시하는 방법은 무엇입니까?

내가 다른 파일이 --ignore-dir=a/b때문으로 a/b을 DIR 무시할 수없는 이름이 다른 파일과 일치 싶어서 --ignore-file=match:c.jsc.js을 무시할 수없는 디렉토리 a/b/c.js

에서 파일이 나는 a/b

내가 해봤 신경 :

--ignore-file=a/b/c.js  "Invalid filter specification" 
--ignore-file=match:/a\/b\/c.js/ 

가 작동하지 않습니다, 나는 ACK 경기의 일부 단지 이름으로 파일 경로를 읽을하지 않기 때문에 그것의 같은데요 :

은 내가 시도했습니다.

이 나는 ​​시도했다 :

--ignore-dir=match:/a\/b\/c.js/  " Non-is filters are not yet supported for --ignore-dir (what?)" 

나는 Ack manual 수프에 유용 아무것도 찾을 수 없습니다. 디렉토리의 파일을 무시하려면 어떻게해야합니까?

답변

1

find ... ! -path ...을 사용하면 특정 경로와 일치하는 이 아닌 파일을 쉽게 검색 할 수 있습니다.

또한 find ... -exec ... \{} \+은 찾은 파일 목록이있는 명령을 실행할 수있게합니다.

내가 손 ack을 가지고 있지 않지만, 장소 보유자로 grep를 사용하여,이 이어질 것 :

sh$ echo toto > a/b/c.js 
sh$ echo toto > a/c.js 
sh$ echo toto > a/b/x.js 
sh$ find . \! -path './a/b/c.js' -type f -exec grep toto \{} \+ 
#  ^  ^      ^^^^ 
#  pattern should match    replace by a call to `ack` 
#  your search path 
./a/c.js:toto 
./a/b/x.js:toto 

편집 : 시작시 ./와 잠재적 인 함정이있다 경로 패턴의 당신이 주어진 파일과 같은 아이 노드를 가진 찾은 파일을 거부 find ... ! -samefile ...를 사용하여 선호 있습니다

sh$ find . \! -samefile a/b/c.js -type f -exec grep toto \{} \+ 
#      ^^^^^^^^ 
#     no dot here; this is a *file* 
#     can't use glob patterns (*, ?, ...) 
./a/c.js:toto 
./a/b/x.js:toto 

man find에서 :

! expr True if expr is false. This character will also usually need 
      protection from interpretation by the shell. 

    -path pattern 
      File name matches shell pattern pattern. The metacharacters do 
      not treat `/' or `.' specially; so, for example, 
        find . -path "./sr*sc" 
      [...] 

    -samefile name 
      File refers to the same inode as name. When -L is in effect, 
      this can include symbolic links. 
관련 문제