Contents

?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
날짜나 파일의 내용으로 검색할 수 있는 방법.. ㅋㅋ

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. [linux] 날짜나 파일의 내용으로 검색하는 방법(find 명령 사용)

    Date2013.04.23 CategoryDevelop Byhooni Views8156
    Read More
  2. [c] GD라이브러리 설치 테스트 소스

    Date2013.04.23 CategoryDevelop Byhooni Views8168
    Read More
  3. [jsp] 페이지에 한글이 정상적으로 보이지 않을 때..

    Date2013.04.23 CategoryDevelop Byhooni Views8175
    Read More
  4. [js] 주민번호 생성기..

    Date2003.04.23 CategoryDevelop Byhooni Views8176
    Read More
  5. [c] 간단한 소켓 프로그래밍 샘플

    Date2013.04.23 CategoryDevelop Byhooni Views8187
    Read More
  6. [c#] 본현이형 논문 자료 (HIDS)ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views8195
    Read More
  7. [c] 프로그래밍 ppt, 스킬업 (비트 수업자료)

    Date2003.04.23 CategoryDevelop Byhooni Views8217
    Read More
  8. [c] 가위 바위 보 서버, 클라이언트 소스코드

    Date2003.04.23 CategoryDevelop Byhooni Views8217
    Read More
  9. [c] 스토리지 클래스(변수)

    Date2003.04.23 CategoryDevelop Byhooni Views8222
    Read More
  10. [vb] 64bit RSA 프로그램 소스 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views8233
    Read More
  11. [c] 그래픽 차트 라이브러리.. 나중에 확인 해볼 거..

    Date2013.04.23 CategoryDevelop Byhooni Views8241
    Read More
  12. [php] 마시마로 캐릭터 방명록

    Date2003.04.23 CategoryDevelop Byhooni Views8266
    Read More
Board Pagination Prev 1 ... 43 44 45 46 47 48 49 50 51 52 ... 98 Next
/ 98