1

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!

2 Answers 2

4

You missed space between name pattern and exec parameter:

This:

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

Should be

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

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.

1
  • 3
    Or use -delete, which will automatically avoid this. Commented Jun 15, 2012 at 11:43

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.