"Find"의 두 판 사이의 차이

ph
이동: 둘러보기, 검색
1번째 줄: 1번째 줄:
* 모든 실행파일 찾기
+
== 모든 실행파일 찾기==
 
일단 file * | grep executable 이 제일 간단함. find명령으로는
 
일단 file * | grep executable 이 제일 간단함. find명령으로는
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
10번째 줄: 10번째 줄:
  
  
* 오늘 바뀐 파일 찾기
+
== 오늘 바뀐 파일 찾기==
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ touch -t `date +%m%d0000` creteria ;  find . -newer creteria -type f
 
$ touch -t `date +%m%d0000` creteria ;  find . -newer creteria -type f
61번째 줄: 61번째 줄:
 
$ find . -name \*jpg -o -name \*JPG -exec echo \{} \; -exec face-detect-using-xml.exe -x cascade.xml \{} \;
 
$ find . -name \*jpg -o -name \*JPG -exec echo \{} \; -exec face-detect-using-xml.exe -x cascade.xml \{} \;
 
</source>
 
</source>
 +
 +
 +
== run multiple exec ==
 +
<pre>find . -name "*.txt" -exec echo {} \; -exec grep banana {} \;</pre>
 +
첫번째 명령 성공해야 두번째도 실행.
 +
무조건 하려면 아래와 같이.
 +
<pre>find . -name "*.txt" \( -exec echo {} \; -o -exec true \; \) -exec grep banana {} \;</pre>[http://stackoverflow.com/a/6043896/766330]
 +
<pre>find . -type d -exec sh -c "echo -n {}; echo -n ' x '; echo {}" \;</pre>
 +
[http://stackoverflow.com/a/13764308/766330]

2017년 4월 9일 (일) 06:15 판

모든 실행파일 찾기

일단 file * | grep executable 이 제일 간단함. find명령으로는

 find . -depth 1 -perm -u+x ! -type d

symbolic link까지 찾는다는게 문제. ! -type l 로 거를 수 있으나 ln의 source file이 executable일 수 있음.

이게 더 낫다.

 find . -executable -type f


오늘 바뀐 파일 찾기

$ touch -t `date +%m%d0000` creteria ;  find . -newer creteria -type f


  • 최근 1분간 바뀐 파일 찾기
$ find . -mmin -1


$ find /<filesystem_name> -xdev -mtime 0 -ls


  • 찾아서 etags
  find . -name '*.cpp' -or -name '*.h' | xargs etags --append

emacs manual에는

 find . -name "*.[chCH]" -print | etags -


 find / -xdev -size  +2048 -ls |sort -r  +6

(+6 option did not work on CentOS 6)


  • find symbolic link files those are not containing 'external' string in their full path.
 find . -wholename '*external*' -prune -o -type l -exec ls -l '{}' \;


$ # prints only one line
$ find / -name blabla\* -print -quit
$
$
$ # execute two (or more) statements
$ # simple. use two (or more) exec commands.
$ find . -name \*jpg -o -name \*JPG -exec echo \{} \; -exec face-detect-using-xml.exe -x cascade.xml \{} \;


run multiple exec

find . -name "*.txt" -exec echo {} \; -exec grep banana {} \;

첫번째 명령 성공해야 두번째도 실행. 무조건 하려면 아래와 같이.

find . -name "*.txt" \( -exec echo {} \; -o -exec true \; \) -exec grep banana {} \;

[1]

find . -type d -exec sh -c "echo -n {}; echo -n ' x '; echo {}" \;

[2]