On using find
find is an extremely powerful command. In order to leave the directory matching *DIRECTORY* out from your search for .txt-files:
find . -path '*DIRECTORY*' -prune -o -iname '*.txt' -print
If you’re using xargs together with find and xargs complains about file names with spaces, use:
find . YOURFINDOPTIONSHERE -print0 | xargs -0 rm -rf
Finding files larger than a certain limit:
find . -size +200M -print0 | xargs -0 ls -lh
Deleting the complementary files:
find . ! -name "*.mp3" -delete
Courtesy of HÃ¥kon.
Please note that these commands pertains to the BSD find as on Mac OS 10.5.
UPDATE 20080517: Looking for file size
UPDATE 20080602: Added deleting complement