Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Feb 2009 22:05:29 -0500
From:      Jaime <>
To:        t-u-t <>
Subject:   Re: shell commands - exclusion
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Wed, Feb 4, 2009 at 9:35 AM, t-u-t <> wrote:
> 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}

I'm just shooting in the dark here, but what about this?

ls | grep -v foo1 | grep -v foo15 | xargs rm -rf

Remember the Unix "pipe" and the grep and xargs commands.  It can
solve a lot of things by stringing together a lot of smaller commands.
 I think that this might be one of those situations.

Good luck,

"To affect the quality of the day, that is the highest of arts."  --
Henry David Thoreau

Tone of voice in email is misunderstood 50% of the time.

Want to link to this message? Use this URL: <>