shell commands - exclusion

Roland Smith rsmith at xs4all.nl
Wed Feb 4 10:03:41 PST 2009


On Wed, Feb 04, 2009 at 03:35:52PM +0100, t-u-t wrote:
> hi, i don't know if this is a freak question, but i was looking around to
> see if this is possible, and what the convention would be.
> 
> if i have say one (or even two) single file/directories among many others,
> and i want to perform any said function like cp, mv, rm, etc.. , to all
> other files except that one or two, is there a way to do that in a single
> command?
> e.g
> rm -r * {-except foo1 foo15}

The easiest way would be to move the few files/directories you don't
want to include in your command out of the way first. :-)

> and if there is, could the same be applied to other similar batch (?)
> operations, like pkg_delete -f "*" { except firefox3 wine thunderbird }
> etc..
I don't think so.

If the couple of files you don't want to rm/whatever you could try using
the find(1) command to get all the other files. The find command is a
very good tool to know.

> i'm a bit new to the shell (took me a while to figure out *ls* and *ls |
> more*), but i can't find anything from google cuz i don't know what this
> would be called in the first place.

Maybe a stupid question, but do you know how to read manual pages?
E.g. for 'find', just enter the command 'man find' in your shell.

> otherwise is it better to protect them with chflags or other trickery?

That would be my other suggestion.

Roland
-- 
R.F.Smith                                   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20090204/bca0d113/attachment.pgp


More information about the freebsd-questions mailing list