linux의 find 명령어를 통해 파일 또는 디렉토리를 검색할 수 있습니다.

기본 사용법

$> find
./test/1.txt
...

응용

  • 현재 디렉토리 아래 모든 파일 및 하위 디렉토리에서 파일 검색
$> find . -name [FILE]
  • 파일 이름이 특정 문자열로 시작하는 파일 검색
$> find . -name "STRING"
  • 파일 또는 디렉토리만 검색
$> find . -name [FILE] -type f

TLDR

$> tldr find

  find

  Find files or directories under the given directory tree, recursively.

  - Find files by extension:
    find root_path -name '*.ext'

  - Find files by matching multiple patterns:
    find root_path -name '*pattern_1*' -or -name '*pattern_2*'

  - Find directories matching a given name, in case-insensitive mode:
    find root_path -type d -iname '*lib*'

  - Find files matching a path pattern:
    find root_path -path '**/lib/**/*.ext'

  - Find files matching a given pattern, excluding specific paths:
    find root_path -name '*.py' -not -path '*/site-packages/*'

  - Find files matching a given size range:
    find root_path -size +500k -size -10M

  - Run a command for each file (use {} within the command to access the filename):
    find root_path -name '*.ext' -exec wc -l {} \;

  - Find files modified in the last 7 days, and delete them:
    find root_path -mtime -7 -delete

Help

$> find --help
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec|time] [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 -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 ;

Please see also the documentation at http://www.gnu.org/software/findutils/.
You can report (and track progress on fixing) bugs in the "find"
program via the GNU findutils bug-reporting page at
https://savannah.gnu.org/bugs/?group=findutils or, if
you have no web access, by sending email to <bug-findutils@gnu.org>.