Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
find . -path '/mnt/ftp/ben/brc' -prune -o -iregex '.*\.\(docx\|xls\|txt\|pdf\|xlsm\|doc\|xlsx\|CVS\|csv\)$'  -mtime +730  -delete

I need all docx, xls, txt, xlms, doc files older than 2 years from my ftp server but also want to exclude /mnt/ftp/ben/brc directory. How can I achieve that?

share|improve this question

1 Answer 1

Try this

find . -path '/mnt/ftp/ben/brc' -prune -o -iregex '.*\.\(docx\|xls\|txt\|pdf\|xlsm\|doc\|xlsx\|CVS\|csv\)$'  -mtime +730  -print0 | xargs -0 rm
share|improve this answer
find . -path '/mnt/ftp/ben/brc' -prune -o -iregex '.*\.(docx\|xls\|txt\|pdf\|xlsm\|doc\|xlsx\|CVS\|csv)$' -mtime +730 -print0 | xargs -0 rm rm: missing operand Try 'rm --help' for more information – user37664 May 6 '13 at 15:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.