Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Removing all directories recursively except one

by skx (Parson)
on Aug 06, 2014 at 06:49 UTC ( #1096394=note: print w/replies, xml ) Need Help??


in reply to Removing all directories recursively except one

Normally people are pretty good at helping here, if you show what you've done and don't just request that people write code for you, for free.

I'd suggest you probably want to start by looking at the File::Find module, as this lets you recurse easily and then take actions on the files.

That said if you just want to get the damn thing done why not use the find command?

find /glb/home/usjak8/myperl ! -iname 'dir3' -print -delete

That will print and delete anything beneath "/glb/home/.." which doesn't have dir3 in the name. If you wished to log just add "| tee ~/delete.log" on the end.

Steve
--
  • Comment on Re: Removing all directories recursively except one

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1096394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2021-02-27 03:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?