Linux
현재 디렉토리만 검색하기 - find current directory only, not recursive/subdirectory
구차니
2010. 2. 26. 20:55
find는 기본적으로 하위 디렉토리를 뒤지도록 되어있기 때문에
강제로 현재 디렉토리만 검색을 하기 위해서는 옵션을 해주어야 한다.
아쉽게도 non-recursive 이런 옵션은 없고
-maxdepth 숫자
라는 옵션이 존재한다.
예를 들어 현재 디렉토리에서 크기가 0인 파일을 찾기 위해서는
$ find ./ -maxdepth 1 -size 0c
이라고 하면된다.
[링크 : http://www.unix.com/unix-dummies-questions-answers/423-using-find-command-only-current-directory.html]
강제로 현재 디렉토리만 검색을 하기 위해서는 옵션을 해주어야 한다.
아쉽게도 non-recursive 이런 옵션은 없고
-maxdepth 숫자
라는 옵션이 존재한다.
예를 들어 현재 디렉토리에서 크기가 0인 파일을 찾기 위해서는
$ find ./ -maxdepth 1 -size 0c
이라고 하면된다.
| find: warning: you have specified the -maxdepth option after a non-option argument -size, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments. maxdepth는 옵션이고 size는 옵션이 아니므로 순서를 반대로 하면 경고를 발생시킨다. |
| -maxdepth levels Descend at most levels (a non-negative integer) levels of directories below the command line arguments. '-maxdepth 0' means only apply the tests and actions to the command line arguments. [링크 : http://linux.die.net/man/1/find] |
[링크 : http://www.unix.com/unix-dummies-questions-answers/423-using-find-command-only-current-directory.html]