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

    Date2013.04.23 CategoryDevelop Byhooni Views8156
    Read More
  2. [jsp][php] 간단한 강좌 자료..

    Date2003.04.23 CategoryDevelop Byhooni Views8155
    Read More
  3. [c] 오류체크(CRC 체크 ) 소스

    Date2013.04.23 CategoryDevelop Byhooni Views8149
    Read More
  4. [c] 반올림 함수!! ㅋㅋ

    Date2003.04.23 CategoryDevelop Byhooni Views8142
    Read More
  5. [c] 컴파일러 DFA구현^^ 입력 받아 실행

    Date2003.04.23 CategoryDevelop Byhooni Views8142
    Read More
  6. [c] 숫자(int, Number)를 hex코드로 변환하는 소스

    Date2013.04.23 CategoryDevelop Byhooni Views8138
    Read More
  7. [c] 레포트용으로 제출했던 여러 소스코드 모음

    Date2003.04.23 CategoryDevelop Byhooni Views8119
    Read More
  8. [c] 유닉스 프로그램에서 인수처리 해주는 getopt() 함수

    Date2013.04.23 CategoryDevelop Byhooni Views8090
    Read More
  9. [js] 셀렉트박스(select)의 옵션(option) 동적으로 추가/제거

    Date2013.04.23 CategoryDevelop Byhooni Views8080
    Read More
  10. [c] 구구단 최단라인 ㅡㅡ;

    Date2013.04.23 CategoryDevelop Byhooni Views8073
    Read More
  11. [c] 프로세스 검사하기

    Date2013.04.23 CategoryDevelop Byhooni Views8048
    Read More
  12. [c] 포인터와 함수포인터에 대해..

    Date2003.04.23 CategoryDevelop Byhooni Views8044
    Read More
Board Pagination Prev 1 ... 28 29 30 31 32 33 34 35 36 37 ... 71 Next
/ 71