Monday, March 03, 2008

Use xargs outside of find

find provides a list of files that match some criteria. This list is passed on to xargs, which then runs some other useful command with that list of files as arguments
find ../ | xargs grep helloword


Find files named ending with .core in or below the directory /tmp and delete them.
find /tmp -name *core | xargs /bin/rm -f

locate files modified less than 10 minutes ago
find / -mmin -10

locate files in data directory size less than 100k (list details)[update:10/21/09]
find ~/data -name *core -type f -size -100k -ls

locate files in data larger than 10M and remove them (using -exec)
find ~/data -size +10M -exec rm -rf {} \;

No comments:

Post a Comment