Develop
2013.04.23 16:11
[linux] 날짜나 파일의 내용으로 검색하는 방법(find 명령 사용)
조회 수 8106 댓글 0
날짜나 파일의 내용으로 검색할 수 있는 방법.. ㅋㅋ
lsh804:~$ find ./ -ctime -7
./
./access-log-previous.gz
./log/html/webchecker
./log/html/webchecker/040906_wc.txt
./log/html/webchecker/040907_wc.txt
./log/html/webchecker/040908_wc.txt
...
$ find ./ -name "*.php" -exec grep "검색문자열" /dev/null {} \;
* 옵션설명
+n for greater than n,
-n for less than n,
n for exactly n.
-atime n
File was last accessed n*24 hours ago.
-ctime n
File's status was last changed n*24 hours ago.
그외의 응용 방법은
[smson@linux smson]$ find ~ -name "*.txt" -print
/home/smson/user2.txt
/home/smson/user3.txt
/home/smson/aa.txt
파일명이 *.bak 이면서 파일크기가 1k 이상인것.
+N 는 이상
-N 는 이하
N 는 정확한 값임
[smson@linux smson]$ find ~ -name "*.bak" -size +1k -print
/home/smson/ihchat/iHChatServer.java.bak
/home/smson/ihchat/iHChatHandler.java.bak
/home/smson/myjava/DatabaseTest.java.bak
는 *.bak 인 파일명을 삭제한다.
-exec는 실행의 의미이면 {} 는 find 로 검색된 파일명이다.
[smson@linux smson]$ find ~ -name "*.bak" -exec rm -rf {} \;
[smson@linux smson]$ find ~ -name "*.bak" -print
[smson@linux smson]$ find ~ -size +100k -exec ls -al {} \;
-rw------- 1 smson smson 1220643 Feb 1 20:56 /home/smson/dead.letter
-rw-rw-r-- 1 smson smson 325923 Aug 14 14:50 /home/smson/aa2.pl.c
-rwxrwxr-x 1 smson smson 526247 Aug 14 14:43 /home/smson/aa
파일내에 문자열검색
[lets114@LETS114 lets114]$ find ./ -name "*.php" -exec grep "검색문자열" /dev/null {} \;
정리를 하면
-name 은 파일명
-size 는 파일크기
-time 는 파일의 시간과 연관된다.
[출처] http://www.ihelpers.co.kr
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
709 | Develop | [matlab] 정보은닉 스테가노그래피(Steganography) 수업 | hooni | 2016.10.03 | 672 |
708 | Develop | [matlab] ZigZag-Scanning (2-D Array) | hooni | 2016.10.15 | 1973 |
707 | Develop | [linux] 프로세스 관련 시스템콜 | hooni | 2003.04.23 | 7827 |
706 | Develop | [linux] 임베디드 리눅스 (embedded linux) | hooni | 2013.04.23 | 7352 |
705 | Develop | [linux] 쉘 스크립트를 이용한 BBS | hooni | 2003.04.23 | 10047 |
» | Develop | [linux] 날짜나 파일의 내용으로 검색하는 방법(find 명령 사용) | hooni | 2013.04.23 | 8106 |
703 | Develop | [linux] tar 명령어 뽀개기.. ㅋㅋ | hooni | 2003.04.23 | 7665 |
702 | Develop | [linux] crond 사용법.. ㅋㅋ | hooni | 2013.04.23 | 7244 |
701 | Develop | [linux] CentOS Apache 웹서버에 HTTPS 적용 | hooni | 2015.10.23 | 775 |
700 | Develop | [lego] 세그웨이 이것만 볼것.. ㅎㅎ | hooni | 2013.04.23 | 33534 |
699 | Develop | [kotlin] 코틀린 안드로이드 앱 버전/빌드 정보 | hooni | 2020.12.15 | 808 |
698 | Develop | [js]모바일 웹에서 orientationchange | hooni | 2013.04.23 | 19355 |