find 명령어 옵션 정리

개요

리눅스의 각종 파일을 찾을수 있도록 도와주는 유용한 명령어이다. 실무에서도 거의 필수적으로 사용되고 있으며, 각종 파일 변경 등의 다중 작업을 수행할때도 많이 사용된다.

그리고 특정소유자의 파일, 소유자가 없는 파일찾기, 특정파일사이즈 이상되는 파일찾기, 지정된 퍼미션(permission)을 가진 파일을 찾을수 있다. 이런 방법으로 매우 다양하고 파워풀한 검색방법을 사용할 수 있는 매우 강력한 리눅스 명령어라고 할 수 있다.

옵션

find명령은 각종파일/디렉토리를 검색할 수 있는 아주 좋은 리눅스 명령어이다.

find [디렉토리] [옵션1] [조건1] [옵션2] [조건2] ……

find ./ -name '*.log'

현재 디렉토리에서(.) 확장자 명이 log인 파일 찾는 명령어이다.

find ./ -name '*.*' -type d

현재 디렉토리에서 파일타입이 d(디렉토리) 로 시작되는걸 검색한 결과이다.

find --help

명령어를 입력하게 되면 아래와 같은 명령어들을 확인할수 있다.

Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions:
operators (decreasing precedence; -and is implicit where no others are given):
      ( EXPR )   ! EXPR   -not EXPR   EXPR1 -a EXPR2   EXPR1 -and EXPR2
      EXPR1 -o EXPR2   EXPR1 -or EXPR2   EXPR1 , EXPR2
positional options (always true): -daystart -follow -regextype
normal options (always true, specified before other expressions):
      -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
      --version -xautofs -xdev -ignore_readdir_race -noignore_readdir_race

tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
      -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
      -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
      -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
      -nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN
      -readable -writable -executable
      -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
      -used N -user NAME -xtype [bcdpfls]
      -context CONTEXT

actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print
      -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
      -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
      -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;

사용법 등을 간단히 설명해 놓은것이다. 자세한 find 명령어 사용법을 알고싶으시면 아래 명령어와 같이 MAN 메뉴얼을 참조하면 된다.

man find

그럼 find 명령어 옵션에 대해서 자세히 나타난다. 한글 리눅스라면 한글설명으로 표현되어 있고, 영문 리눅스라면 영어로 표시된다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 항목은 *(으)로 표시합니다