파일 검색

이 문서는 RHEL7 환경에서 테스트 후 작성된 문서 입니다.
추후 부분적인 추가 작업이 있을 수도 있습니다.

기본 명령어 형식은 find [찾을 디렉토리] [찾기 옵션] [찾은 후 실행할 작업]

전체 하드 디스크에서 검색

명령어 : find / -name '*.확장자'

[root@localhost ~]# find / -name '*.c'
/usr/lib/firmware/isci/create_fw.c
/usr/share/doc/systemd/sd-readahead.c
/usr/share/doc/ppp-2.4.5/scripts/chatchat/chatchat.c
현재 경로에서 디스크 검색

명령어 : find -name '*.확장자'

[root@localhost ~]# find -name '*.c'
./sample.c

검색 시 해당 파일이 없는 상태에서는 문구조차 나오지 않는다.

[root@localhost ~]# find -name '*.c

[root@localhost ~]#




전체 하드디스크에서 검색

명령어 : find / -name '파일명'

[root@localhost ~]# find / -name 'sample'
/usr/share/doc/ppp-2.4.5/sample
전체 하드디스크에서 모든 확장자 포함 검색

명령어 : find / -name '파일명.*'

[root@localhost ~]# find / -name 'sample.*'
/root/sample.txt
/root/sample.c
/usr/share/doc/sudo-1.8.6p7/sample.pam
/usr/share/doc/sudo-1.8.6p7/sample.sudo.conf
/usr/share/doc/sudo-1.8.6p7/sample.sudoers
/usr/share/doc/sudo-1.8.6p7/sample.syslog.conf
/data/sample.txt
전체 하드디스크에서 일부 검색어로 검색

명령어 : find / -name '파일명*'

[root@localhost ~]# find / -name 'sample*'
/root/sample.txt
/root/sample.c
/usr/share/doc/ppp-2.4.5/sample
/usr/share/doc/redhat-support-tool-0.9.6/samples
/usr/share/doc/sudo-1.8.6p7/sample.pam
/usr/share/doc/sudo-1.8.6p7/sample.sudo.conf
/usr/share/doc/sudo-1.8.6p7/sample.sudoers
/usr/share/doc/sudo-1.8.6p7/sample.syslog.conf
/data/sample.txt
현재 경로에서 검색

명령어 : find -name '파일명'

[root@localhost ~]# find -name 'basic'
./basic
현재 경로에서 모든 확장자 포함 검색

명령어 : find -name '파일명.*'

[root@localhost ~]# find -name 'basic.*'
./basic.txt
./basic.c
./basic.pl
현재 경로에서 일부 검색어로 검색

명령어 : find -name '파일명*'

[root@localhost ~]# find -name 'ba*'
./basic
./basic.txt
./basic.c
./basic.pl
특정 디렉토리에서 검색

명령어 : find ./디렉토리경로 -name '파일명*'

[root@localhost ~]# find ./test -name 'grep*'
./test/greptest.txt

전체 디스크에서 특정 유저가 생성한 파일 검색

명령어 : find / -user 유저명

[root@localhost ~]# find / -user zzung
/var/spool/mail/zzung
/home/zzung
/home/zzung/.bash_logout
/home/zzung/.bash_profile
/home/zzung/.bashrc
/home/zzung/zzung_sample.txt
/home/zzung/zzung_sample2.txt
/home/zzung/zzung_sample3.txt
/home/zzung/.bash_history

grep 명령어 기본 문법
grep [-옵션] 패턴파일명
로그인하면 댓글을 남길 수 있습니다.
  • 파일_검색.txt
  • 마지막으로 수정됨: 2015/06/18 15:49
  • 저자 127.0.0.1