find, xargs

Originally shared by Xah Lee

: the most powerful shell command. Master it. find, xargs. Here’s some commen patterns:

#  show just files ending with .html

find . -name “*.html”

# larger than 9 Mega bytes

find . -size +900000c

# delete all files whose name ends with ~.

find . -name “*~” -exec rm {} \;

# delete all empty files

find . -type f -empty -exec rm {} \;

# delete empty dirs

find . -depth -empty -type d -exec rmdir {} \;

# file status changed in last 60 min

find . -cmin -60

# file content modified in last 60 min

find . -mmin -60

for more, using xargs examples, see

http://xahlee.info/linux/linux_shell_find_example.html

 

Leave a Reply