find
하위 디렉토리로 재귀하지 않는 방식으로 명령 을 사용할 수 있습니까? 예를 들어
DirsRoot
|-->SubDir1
| |-OtherFile1
|-->SubDir2
| |-OtherFile2
|-File1
|-File2
그리고 같은 결과는 find DirsRoot --donotrecuourse -type f
오직 File1, File2
?
답변
-maxdepth 1
현재 명령 구조에 따라 옵션으로 원하는 것을 얻을 수 있다고 생각합니다 . 그렇지 않은 경우에 대한 맨 페이지 를 참조하십시오find
.
관련 항목 (편의를 위해) :
-maxdepth levels
Descend at most levels (a non-negative integer) levels of direc-
tories below the command line arguments. `-maxdepth 0' means
only apply the tests and actions to the command line arguments.
옵션은 기본적으로 다음과 같습니다.
find DirsRoot/* -maxdepth 0 -type f #This does not show hidden files
또는:
find DirsRoot/ -maxdepth 1 -type f #This does show hidden files
답변
나는 당신이 찾고 있다고 생각합니다 -maxdepth 1
.
답변
POSIX 호환 솔루션을 찾는 경우 :
cd DirsRoot && find . -type f -print -o -name . -o -prune
-maxdepth 는 POSIX 호환 옵션이 아닙니다.