[Shell] 특정 크기 이상인 파일 찾기

ITWeb/개발일반 2018. 8. 28. 12:43

- 2MB 이상 파일 찾기

$ find * -size +2M -type f | wc -l


- 2MB 이상 파일 삭제 하기

$ find * -size +2M -type f -exec rm -f '{}' \;


args1 = <where to find>
args2 = <find by what, which means it could be -name, -type and here we give -size to mean we wish to find files by size>
args3 = <what size.. +10k would mean above 10 kilo bytes>
args4 = <and one more condition .. -type, which means what type of things should it match>
args5 = <-f means files.. we could have mentioned -d (directory) -b (block), -c (character), -f (regular file), -l (link), -s (socket), -p (pipes) >
args6 = <-exec means what action to perform if all the matches are true, so -exec is for action..>
args7..10 = < the following of -exec is a shell command..
rm -f {} \; this means the results of match is removed (deleted)>

: