Programing

재귀없이 찾기

lottogame 2020. 4. 14. 08:23
반응형

재귀없이 찾기


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 호환 옵션이 아닙니다.

참고 URL : https://stackoverflow.com/questions/3925337/find-without-recursion

반응형

'Programing' 카테고리의 다른 글

MySQL을 사용하고 있습니까?  (0) 2020.04.14
jQuery 맵과 각각  (0) 2020.04.14
C #에서 Excel 파일 읽기  (0) 2020.04.14
신뢰 저장소와 키 저장소-keytool로 작성  (0) 2020.04.14
C #의 트리 데이터 구조  (0) 2020.04.14