http://qs321.pair.com?node_id=1096394


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