[Gllug] quick question - exclusive rm -r
Luis M. Cruz
luismcv at gmail.com
Mon Nov 27 10:38:56 UTC 2006
On 11/27/06, salsaman <salsaman at xs4all.nl> wrote:
> Is it possible to say "delete all subdirectories of ., _except_ those
> containing the file foo" in one line of shell script ? If so, how ?
Hi,
something like this should work:
for A in `find -type d`; do echo `find -type f -name foo` | grep -q $A
|| rm -fr $A ; done
Anyway, use it with care. Make a copy of your files before trying it.
Cheers!
--
______________________________________________________________________________
Luis M. Cruz <luismc at fraggelrock.com> Systems
Administrator/Developer
PGP keyIDs: 0x6848D470 (DSS) / 0x255E9505 (RSA)
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list