These are the find commands that I use regularly.
find . -type d -empty -exec rmdir {} \;
A far more efficient approach to the above. If no path is provided, then the current working directory (CWD) is assumed, making the .
superfluous.
find -type d -empty -delete
find . -type f -exec chmod 644 {} \;
Find files with extension .png
, then rename their extension to .jpg
. It's highly important that \;
is used here, instead of \+
, otherwise it'd make a right mess of the files, due to the way in which mv(1) works.
find . -type f -iname '*.png' -exec bash -c 'mv "$0" "${0%.*}.jpg"' {} \;
find . -type d
find . -iname "*.jpg"
# To find files with extension '.txt' and remove them:
find ./path/ -name '*.txt' -exec rm '{}' \;
find ./path/ -name '*.txt' | xargs grep 'string'
find . -size +5M -type f -print0 | xargs -0 ls -Ssh | sort -z
find . -type f -size +200000000c -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
find . -type f -mtime +7d -ls
find . -type l -user <username-or-userid> -ls
find . -maxdepth 2 -name build -type d
find . ! -iwholename '*.git*' -type f
find root_path -name '*pattern_1*' -or -name '*pattern_2*'
find root_path -path '**/lib/**/*.ext'
find root_path -size +500k -size -10M
find root_path -name '*.ext' -exec wc -l {} \;
find root_path -mtime -7 -delete