![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to display directories recursively? | jwriter | UNIX for Dummies Questions & Answers | 5 | 04-23-2007 03:37 PM |
| deleting directories from a list | amacgeek | Filesystems, Disks and Memory | 1 | 04-10-2006 01:07 AM |
| deleting all the sub directories | pavan_test | UNIX for Dummies Questions & Answers | 2 | 01-26-2006 10:52 PM |
| deleting nfs directories... | piltrafa | UNIX for Dummies Questions & Answers | 3 | 01-30-2003 12:33 PM |
| deleting log files only in particular directories | sameervs | UNIX for Dummies Questions & Answers | 2 | 06-01-2002 01:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Recursively deleting directories
Say I have a directory call test, and several directories nested in it, and several directories nested in them. And I want to remove all directories within "test" and its subdirectories that have the name "cvs", how can I do this?
I tried rm -r cvs, but that only removed the top level direcotry name cvs. Thanks for any help |
|
|||||
|
No problem.
You are correct - "-type d" does indeed mean directories. Specifically it tells find to only match files of type "directory". This can also be f for regular files, l for symlinks, etc - "man find" will detail the plethora of options available for find - an extrememly powerful command. The | xargs bit is used to pipe the results from find (i.e. the list of directories) to the rm -r command, so that the command can then be executed. We could also have formed the find command thusly: find /path/to/test -name "cvs" -type d -exec rm -r {} \; and it would have done pretty much the same thing. xargs is useful when the number of results returned by find exceeds the maximum number of arguments allowed by the command we're piping to. Using find with "exec" would have sufficed here, but xargs is habit (and I believe, good practice) for me. man find, man xargs, man <my_shell_here> will teach you more about the find and xargs commands - and pipes and redirection. Cheers ZB Last edited by zazzybob; 11-26-2004 at 11:00 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|