본문 바로가기
카테고리 없음

[Utils] find

by 크크다스 2017. 7. 1.
반응형

Linux command: How to 'find' only text files?

출처> https://stackoverflow.com/questions/4767396/linux-command-how-to-find-only-text-files



find . -type f -exec grep -Iq . {} \; -and -print

The -I option to grep tells it to immediately ignore binary files and the . option along with the -q will make it immediately match text files so it goes very fast. You can change the -print to a -print0 for piping into an xargs -0 or something if you are concerned about spaces (thanks for the tip, @lucas.werkmeister!)

Also the first dot is only necessary for certain BSD versions of find such as on OS X, but it doesn't hurt anything just having it there all the time if you want to put this in an alias or something

a tfind="${FIND} . -type f -exec grep -Iq . {} \\; -and -print"

`find -name` pattern that matches multiple patterns

출처> https://stackoverflow.com/questions/1133698/find-name-pattern-that-matches-multiple-patterns

Use -o, which means "or":
find Documents \( -name "*.py" -o -name "*.html" \)\


위 두가지 조합> 필요할까만은.....


find . -name "*.c" -o -name "*.h" -type f -exec grep -Iq . {} \; -and -print



참고> Linux command: How to 'find' only text files?


Linux : find . -type f -exec grep -Iq . {} \; -and -print


OS-X :find . -type f -exec grep -Il "" {} \; -and -print


Fast :find . -type f -exec grep -Il . {} +




참고> Linux command: How to 'find' only text files?

Linux : find . -type f -exec grep -Iq . {} \; -and -print

OS-X :find . -type f -exec grep -Il "" {} \; -and -print

Fast :find . -type f -exec grep -Il . {} +


File Size 로 찾기

_N_ : +N / -N / N

이상 / 이하 / Same

_B_ : c / w / b / k

1 / 2 / BLOCK size / Kilo byte(s)

find . -size _N__B_

Ex> 1Mega bytes 이상 10Mega bytes 이하 찾기

find . -size +1000k -size -10000k

검색 후 삭제

-exec rm -rf {} \;



user / group 으로 찾기

-user name

-group grp_name


symbolic link 소유자 바꾸기 : -h

chown firstpw:firstpw -h ....



반응형