검색 릭 링크를 찾는 방법은 무엇입니까?
특정 패턴을 따르는 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
'ProgramingTip' 카테고리의 다른 글
경고 : Visual Paradigm에서 코드 생성에 사용할 수있는 클래스 모델이 없습니다. (0) | 2020.12.09 |
---|---|
더 많은 iCloud Core 데이터 동기화 문제 (0) | 2020.12.09 |
fetch (key) 오류 : 지연로드 데이터베이스 (0) | 2020.12.08 |
"예외를 사용하지 않는"캠프에있는 경우 표준 라이브러리를 어떻게 사용합니까? (0) | 2020.12.08 |
docker-compose를 통해 Docker 컨테이너에 고정 IP 제공 (0) | 2020.12.08 |