Recursively chmod for directories:
1 |
find . -type d -exec chmod 775 {} \; |
Recursively chmod for files:
1 |
find . -type f -exec chmod 664 {} \; |
Find specific filename:
1 |
find . -name autorun.inf -print |
Find a specified file with maximum 2 directories depth:
1 |
find . -maxdepth 2 -name autorun.inf -type f -print |
Find a specified file in locate db:
1 |
locate autorun.inf |
Find all files bigger than 30MB:
1 |
find -type f -size +30M -exec ls -al ‘{}’ \; |
Find all files with extensions doc xls and pdf:
1 2 |
find -type f -iname “*.doc” -or -iname “*.xls” -or -iname “*.pdf” -print find -type f -iregex “.*.(doc|xls|pdf)” -print |
Find all files except with extensions doc xls and pdf:
1 |
find -type f ! -iregex “.*.(doc|xls|pdf)” -print |
Find all files modified 30 days ago:
1 |
find -type f -mtime 30 -print |
Find files like IMG_1234 1.JPG and delete them (tested on MAC)
1 |
find -E . -regex '.*/IMG_[0-9]{4}[ ]1.JPG' -print -exec rm '{}' \; |
Find files like 509b790a273c0 and delete them (tested on CENTOS)
1 |
sudo find . -regextype posix-extended -regex './50[0-9a-z]{11}' -print |
Find files that differ between 2 directories
1 |
diff -rq todo_orig/ todo_backup/ |