[Gllug] quick question - exclusive rm -r

Progga progga at BengaLinux.Org
Mon Nov 27 12:59:23 UTC 2006


On Mon, Nov 27, 2006 at 02:21:46AM +0100, salsaman 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 ?

The following works in my FreeBSD box under bash:

$ find ./ -type d -not -exec [ -e {}/foo ] \; -delete
find: -delete: ./: relative path potentially not safe

The error msg can be ignored.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20061127/c366d6ce/attachment.pgp>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list