Useful Unix find commands

~ 1 min read

I’m always forgetting those killer unix find commands, so I thought I’d share my scrap book of one liner finds here:

find all zero byte files

find . -size 0

find and remove all zero byte files

find . -size 0 -exec rm -v '{}' \;

find files modified in the last 5 days

find . -mtime -5

find files modified over 5 days ago

find . -mtime +5

find the top 10 largest files

Your running out of disk space and need to find those big files, so you can either archive or delete them. Then this puppy is for you, 10 biggest files in the current path and it’s sub-directories.

find . -type f -printf '%s %p\n'| sort -nr | head -10

all posts →