View previous topic :: View next topic |
Author |
Message |
DaveAnderson n00b
Joined: 04 Jan 2004 Posts: 59
|
Posted: Mon Nov 22, 2004 3:49 pm Post subject: Help me write a simple script |
|
|
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 |
|
|
BlackEdder Advocate
Joined: 26 Apr 2004 Posts: 2588 Location: Dutch enclave in Egham, UK
|
Posted: Mon Nov 22, 2004 4:02 pm Post subject: |
|
|
find ./ -name 'spam' -type d -exec rm -r {} \;
(You might wanna add an i to the -r at first ) |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20093
|
Posted: Mon Nov 22, 2004 4:12 pm Post subject: |
|
|
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 |
|
|
|