ProgramingTip

검색 릭 링크를 찾는 방법은 무엇입니까?

bestdevel 2020. 12. 8. 19:22
반응형

검색 릭 링크를 찾는 방법은 무엇입니까?


특정 패턴을 따르는 Linux에서 파일을 찾고 싶지만 있습니다.

find그것에 , 대한 명령에, 대한 옵션이없는을 구석으로 같습니다 .

어떻게해야합니까?


맨 페이지를 확인 하십시오.) 다음과 다시 확인 하십시오.

find /path/to/files -type f

type f 검색 릭 링크를 일반 파일 만 검색합니다.


! -type l

예를 들어, symlink를 제외하고 / usr / bin에있는 모든 일반 파일을 검색하려는 경우 :

find /usr/bin/ \! -type l

수신 릭 링크를 사용하지만 반환하지 않기를 원합니다 (패턴과 일치하는 경우)?

find -H?

man find
     ...
     -H      Cause the file information and file type (see stat(2)) returned for each symbolic link specified on the command line to be those of
             the file referenced by the link, not the link itself.  If the referenced file does not exist, the file information and type will be
             for the link itself.  File information of all symbolic links not on the command line is that of the link itself.

     -L      Cause the file information and file type (see stat(2)) returned for each symbolic link to be those of the file referenced by the
             link, not the link itself.  If the referenced file does not exist, the file information and type will be for the link itself.

             This option is equivalent to the deprecated -follow primary.

나는 MAN을 읽습니다 이제 -P도 -type r을 사용하면 오류가 발생합니다. 이제 DEFAULT 동작도 주목하십시오.

-P 전화 번호 릭 링크를 따라 가지 이것이 기본 동작입니다. 검색이 파일 정보를 검사하거나 인쇄하고 파일이 검색된 링크 인 경우 사용되는 정보는있는 릭 링크 자체의 속성에서 가져옵니다.


@AquariusPower가 말했듯이 사용은 find -type f -xtype f내 문제 해결하고 이제 더 이상 기호 링크가 아닌 실제 파일 만 얻습니다.

출처 : https://linux.die.net/man/1/find

나는 이유 :

-xtype c 파일이 소유 한 링크가 아닌 경우 -type과 동일합니다. 기호 링크의 경우 : -H 또는 -P 옵션이 지정된 경우 파일이 c 유형의 파일에 대한 링크이면 true이고, -L 옵션이 경우 경우 c가 'l'이면 true입니다. 즉, 검색 릭 링크의 경우 -xtype은 -type이 확인되지 않는 파일 유형을 확인합니다.

감사합니다.


이것은 나를 위해 작동합니다.

find -H . -maxdepth 1 -type f

실제로 -H는 필요하지 않습니다.

참고 URL : https://stackoverflow.com/questions/16303449/how-to-find-files-except-symbolic-links

반응형