Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Removing all directories recursively except one

by skx (Parson)
on Aug 06, 2014 at 06:49 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1096394]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found