Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

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
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.