Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Help me write a simple script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
DaveAnderson
n00b
n00b


Joined: 04 Jan 2004
Posts: 59

PostPosted: Mon Nov 22, 2004 3:49 pm    Post subject: Help me write a simple script Reply with quote

Probably not even a script. I just need a command that will start at the current directory (./) and go through all subdirectories and remove (rm -rf spam) any folder named spam.
Back to top
View user's profile Send private message
BlackEdder
Advocate
Advocate


Joined: 26 Apr 2004
Posts: 2588
Location: Dutch enclave in Egham, UK

PostPosted: Mon Nov 22, 2004 4:02 pm    Post subject: Reply with quote

find ./ -name 'spam' -type d -exec rm -r {} \;

(You might wanna add an i to the -r at first :))
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Mon Nov 22, 2004 4:12 pm    Post subject: Reply with quote

Test:
Code:
find ./ -type d -name spam -print0 |xargs -0 rm

Do:
Code:
find ./ -type d -name spam -print0 |xargs -0 rm -rf


xargs takes all output from find and executes one command, whereas -exec will run rm for each dir. Doesn't make much difference for small find results, but if you have a lot, it adds up.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum