Contents

?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
날짜나 파일의 내용으로 검색할 수 있는 방법.. ㅋㅋ

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


?

  1. [js] 후리자(영규) 스타일들..

    Date2013.04.23 CategoryDevelop Byhooni Views7184
    Read More
  2. [js]모바일 웹에서 orientationchange

    Date2013.04.23 CategoryDevelop Byhooni Views19432
    Read More
  3. [kotlin] 코틀린 안드로이드 앱 버전/빌드 정보

    Date2020.12.15 CategoryDevelop Byhooni Views998
    Read More
  4. [lego] 세그웨이 이것만 볼것.. ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views33592
    Read More
  5. [linux] CentOS Apache 웹서버에 HTTPS 적용

    Date2015.10.23 CategoryDevelop Byhooni Views929
    Read More
  6. [linux] crond 사용법.. ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views7280
    Read More
  7. [linux] tar 명령어 뽀개기.. ㅋㅋ

    Date2003.04.23 CategoryDevelop Byhooni Views7817
    Read More
  8. [linux] 날짜나 파일의 내용으로 검색하는 방법(find 명령 사용)

    Date2013.04.23 CategoryDevelop Byhooni Views8167
    Read More
  9. [linux] 쉘 스크립트를 이용한 BBS

    Date2003.04.23 CategoryDevelop Byhooni Views10084
    Read More
  10. [linux] 임베디드 리눅스 (embedded linux)

    Date2013.04.23 CategoryDevelop Byhooni Views7387
    Read More
  11. [linux] 프로세스 관련 시스템콜

    Date2003.04.23 CategoryDevelop Byhooni Views7876
    Read More
  12. [matlab] ZigZag-Scanning (2-D Array)

    Date2016.10.15 CategoryDevelop Byhooni Views2123
    Read More
Board Pagination Prev 1 ... 54 55 56 57 58 59 60 61 62 63 ... 71 Next
/ 71