Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use Dreamweaver to upload the web page to my site, it bring a folder called _note to everywhere in my site. I would like to ask how can I loop in the directory(/home/user/htdocs) to find the folder _note and delete it?

share|improve this question
up vote 3 down vote accepted

Assuming you have a shell on the webserver, this command would do it:

find /home/user/htdocs -type d -name _note -exec rm -rfv "{}" \;

However I would be more careful then that. I would start by doing this to get a list and make sure its good:

find /home/user/htdocs -type d -name _note -exec echo "'{}'" \; > file.txt

Then review the file and if its all good:

cat file.txt | xargs rm -fvr 

That way you can catch errors before you delete critical files.

share|improve this answer
Very useful of the information, btw what is "{}" in the command line? – Charles Yeung Apr 18 '11 at 4:51
the {} puts each result of the find command in the command you are running with the -exec flag. So in the first example, I search for all directories named _note and then execute the command rm -rfv the directory name. I add quotes, so that if you have a directory like: Files / Folders ... it does not try to remove /. – n8whnp Apr 18 '11 at 5:31

You can use lftp with rm -r to recursively remove a folder/file pattern/name. I think there is command line version of lftp for Windows that you can download and install.

share|improve this answer

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.