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?

link|improve this question

60% accept rate
feedback

2 Answers

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.

link|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
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.