Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What's difference between this:

sudo find /usr/local/mysql/data -type f -exec rm {} ';'

and this:

sudo rm -rf /usr/local/mysql/data
share|improve this question
add comment

3 Answers

up vote 4 down vote accepted
sudo find /usr/local/mysql/data -type f -exec rm {} ';'

sudo will make it run as root, then you use find -type f to get all the files(just files) in /usr/local/mysql/data

the -exec rm{} will be called for each item found and will remove the file.

So this will remove files recursively but it will NOT remove any directories. Also not that the rm command is used without -f argument(force)

rm -rf /usr/local/mysql/data

This command will completely remove everything in the given path, directories and files are removed. -f is used so there will be no prompts for the issuing user.

share|improve this answer
    
so the curlies {} will contain the results of the find… -type f portion of the statement when rm is executed? –  Meltemi Jun 5 '10 at 0:18
    
yes, you are correct Meltemi. When using find in combination of -exec the String {} will be replaced with the full path to the current file. –  S.Hoekstra Jun 5 '10 at 8:12
add comment

The former will remove only files. The latter will remove the entire directory structure.

share|improve this answer
    
what's the ';' mean? –  Meltemi Jun 4 '10 at 16:21
1  
It terminates the -exec predicate. –  Ignacio Vazquez-Abrams Jun 4 '10 at 16:35
    
meaning, you could add another -exec doing something else ... –  akira Jun 4 '10 at 17:36
    
Meaning you can add another predicate without it being interpreted as an argument for the command in the -exec predicate. –  Ignacio Vazquez-Abrams Jun 4 '10 at 17:41
add comment

find /usr/local/mysql/data -type f -delete will delete only regular files. Directories will stay

rm -rf /usr/local/mysql/data Will remove anything.

share|improve this answer
add comment

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.