Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have 4 large USB devices with lots of backups collected over the years.

I want to search for all .Trash folders and delete the contents on Fedora 17. I tried the following which failed:-

    # find . -name ".Trash*"-exec rm -rf {} \;
    find: paths must precede expression: rm
    Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

Any hints appreciated!

share|improve this question

2 Answers 2

up vote 1 down vote accepted

To expand on @rkosegi's answer:

 # find . -depth -name ".Trash*" -exec rm -rf {} \;

Use -depth so that find doesn't try to descend the now deleted directory.

share|improve this answer
3  
Or use -delete, which will automatically avoid this. –  Chris Down Jun 15 '12 at 11:43

You missed space between name pattern and exec parameter:

This:

 # find . -name ".Trash*"-exec rm -rf {} \;

Should be

 # find . -name ".Trash*" -exec rm -rf {} \;
share|improve this answer

Your Answer

 
discard

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.