Darkland | net

Find Commands That Rock

Published on 20 April 2014 by Amanda

find [path] -type d -ctime -2 -exec ls {} \;
find [path] -type d -ctime -2 -prune
find [path] -type d -ctime -2 -maxdepth 1
find [path] -type d -ctime 1 -maxdepth 1 -exec ls {} \;
find [path] -type d -ctime -1 -maxdepth 1 -exec ls {} \;
find [path] -type d -ctime -1 -maxdepth 1

Find empty directories or files:
Reference: https://www.putorius.net/find-and-delete-empty-directories-linux.html find [path] -type d -empty
find [path] -type f -empty or find [path] -type f -size 0 and delete them find [path] -type d -empty -delete
find [path] -type f -empty -delete or find [path] -type f -empty -exec rm {} \; or find [path] -type f -empty | xargs rm -f
This is the find command I seem to use most. It uses exec to run chmod on the results of the find. $ find [path] -type f -exec chmod -v 755 {} \;
Find files, in this case *png and resize them to XxY find [path] -type f -name "*png" -exec convert -resize 320x276 {} {} \;
The following command finds file modified over 720 days ago. $ find [path] -type f -mtime +720 -exec ls -l {} \;
The following command finds directories created over 60 days ago and shows their size. $ find [path] -type d -ctime +60 -exec du -sh {} \;
The following command finds directories in the in the current directory (.) that have changed in the last 24 hours without recursion. $ find [path] -maxdepth 1 -type d -ctime -1
This command will find all files that contain the word douche whether it starts with an uppercase D or lowercase d: $ find [path] -type f -name "*[D|d]ouche*"
This copies files found by find. $ find [path] -type f -name *mp3 -exec cp {} ../output/ \; You can also change cp to mv to move files. I usually just cp them then delete the source files. it helps prevent, "OH SHIT," moments. $ mv "*[F,f]ilename*" /destination/directory/
Back