![GNU find를 사용하여 한 번에 여러 파일 형식을 검색하는 방법은 무엇입니까?](https://linux55.com/image/71177/GNU%20find%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%ED%95%9C%20%EB%B2%88%EC%97%90%20%EC%97%AC%EB%9F%AC%20%ED%8C%8C%EC%9D%BC%20%ED%98%95%EC%8B%9D%EC%9D%84%20%EA%B2%80%EC%83%89%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
GNU find 명령을 사용하여 한 번에 여러 파일 형식을 일치시키는 방법(하나의 검색 명령)?
매뉴얼 페이지에는 다음과 같이 나와 있습니다.
-type c
File is of type c:
b block (buffered) special
c character (unbuffered) special
d directory
p named pipe (FIFO)
f regular file
l symbolic link; this is never true if the -L option or the -follow
option is in effect, unless the symbolic link is broken. If
you want to search for symbolic links when -L is in effect, use
-xtype.
s socket
D door (Solaris)
f
파일( )과 심볼릭 링크( l
)를 검색하여 다른 프로세스로 파이프하고 싶습니다 . 동시에 검색하는 방법은 무엇입니까?
나는 열심히 노력했다
find -type fl | …
find -type f -type l | …
find -xtype f -type l | …
해결책은 서브쉘을 사용하는 것이라는 것을 알고 있습니다.
(find -type f; find -type l) | …
하지만 난 그냥 알고 싶어만약에가능한.
답변1
find를 사용하여 논리 연산자를 그룹화하고 사용할 수 있지만 모든 파일과 링크를 찾으려면 대괄호를 이스케이프해야 합니다.
find \( -type f -o -type l \) <other filters>
따라서 이름이 t로 시작하는 모든 파일과 링크를 원하면 다음을 수행할 수 있습니다.
find \( -type f -o -type l \) -name 't*'
괄호는 항목을 그룹화하고 다른 연산자와 결합하려는 경우에만 필요하므로 다른 검색 기준이 없으면 생략할 수 있습니다.
답변2
이 시도:
find -type f -o -type l
답변3
-a
and
(for ) 또는 (for ) 를 사용하여 -o
조건자를 결합 할 수 있습니다 or
. 따라서 다음을 입력할 수 있습니다.
find /path -type f -o -type l