| Author |
delete all files except files ending with xxx
|
|
|
| any way to do that?
I have a directory with a bunch of files. I want to remove all files
except files that end with *xxx.
Thanks for any help or information.
| |
| james19390@yahoo.com 2007-05-18, 1:23 pm |
| On May 18, 12:29 pm, jobs <j...@webdos.com> wrote:
> any way to do that?
>
> I have a directory with a bunch of files. I want to remove all files
> except files that end with *xxx.
>
> Thanks for any help or information.
find . ! -name '*xxx' -delete
find acts recursively by default, so be careful
| |
| Kenny McCormack 2007-05-18, 1:23 pm |
| In article <1179505759.781934.150260@l77g2000hsb.googlegroups.com>,
jobs <jobs@webdos.com> wrote:
>any way to do that?
>
>I have a directory with a bunch of files. I want to remove all files
>except files that end with *xxx.
I assume you mean "end with xxx". It would be weird if their names
actually ended with *xxx.
>Thanks for any help or information.
>
The easy way:
mkdir temptemp
mv *xxx temptemp
rm -f * 2>/dev/null
mv temptemp/* .
rmdir temptemp
But you are probably looking for some more complicated than this.
| |
| Dan Mercer 2007-05-18, 1:23 pm |
| In ksh:
rm -f !(*xxx)
Dan Mercer
<james19390@yahoo.com> wrote in message news:1179510495.206341.192360@o5g2000hsb.googlegroups.com...
: On May 18, 12:29 pm, jobs <j...@webdos.com> wrote:
: > any way to do that?
: >
: > I have a directory with a bunch of files. I want to remove all files
: > except files that end with *xxx.
: >
: > Thanks for any help or information.
:
: find . ! -name '*xxx' -delete
: find acts recursively by default, so be careful
:
| |
|
| On May 18, 2:10 pm, "Dan Mercer" <damer...@comcast.net> wrote:
> In ksh:
>
> rm -f !(*xxx)
>
> Dan Mercer
>
> <james19...@yahoo.com> wrote in messagenews:1179510495.206341.192360@o5g2000hsb.googlegroups.com...
>
> : On May 18, 12:29 pm, jobs <j...@webdos.com> wrote:
> : > any way to do that?
> : >
> : > I have a directory with a bunch of files. I want to remove all files
> : > except files that end with *xxx.
> : >
> : > Thanks for any help or information.
> :
> : find . ! -name '*xxx' -delete
> : find acts recursively by default, so be careful
> :
nice. any way to do the same thing in bash? I'm on Solaris.
| |
|
| On May 18, 1:48 pm, james19...@yahoo.com wrote:
> On May 18, 12:29 pm, jobs <j...@webdos.com> wrote:
>
>
>
>
> find . ! -name '*xxx' -delete
> find acts recursively by default, so be careful
that did not work in solaris bash, and i tried this but it produces
the .
find . ! -name '*xxx' |xargs rm
| |
| fsoppelsa@gmail.com 2007-05-18, 7:17 pm |
| On May 18, 6:29 pm, jobs <j...@webdos.com> wrote:
> any way to do that?
>
> I have a directory with a bunch of files. I want to remove all files
> except files that end with *xxx.
>
> Thanks for any help or information.
Have you tried the following?
% rm -f `ls | grep -v xxx$`
| |
| Bill Marcum 2007-05-18, 7:17 pm |
| On 18 May 2007 11:47:47 -0700, jobs
<jobs@webdos.com> wrote:
>
>
> On May 18, 2:10 pm, "Dan Mercer" <damer...@comcast.net> wrote:
>
> nice. any way to do the same thing in bash? I'm on Solaris.
>
shopt -s extglob
--
The sooner our happiness together begins, the longer it will last.
-- Miramanee, "The Paradise Syndrome", stardate 4842.6
| |
| Bill Marcum 2007-05-18, 7:17 pm |
| On 18 May 2007 11:51:28 -0700, jobs
<jobs@webdos.com> wrote:
>
>
> On May 18, 1:48 pm, james19...@yahoo.com wrote:
>
> that did not work in solaris bash, and i tried this but it produces
> the .
> find . ! -name '*xxx' |xargs rm
>
find is an external command, not dependent on which shell you use, but
the GNU and BSD versions of find have some nonstandard options.
--
He who has the courage to laugh is almost as much a master of the world
as he who is ready to die.
-- Giacomo Leopardi
| |
| Jean-Rene David 2007-05-19, 1:20 am |
| * jobs [2007.05.18 16:29]:
> I have a directory with a bunch of files. I want to remove
> all files except files that end with *xxx.
Using zsh:
non recursive:
rm *~*xxx(.)
recursive:
rm **/*~*xxx(.)
HTH,
--
JR
| |
| Stephane CHAZELAS 2007-05-19, 1:20 pm |
| 2007-05-18, 20:00(-05), Jean-Rene David:
> * jobs [2007.05.18 16:29]:
>
> Using zsh:
>
> non recursive:
> rm *~*xxx(.)
Or
rm ^*xxx
(needs setopt extendedglob).
zsh also knows recognises the ksh syntax after a
setopt kshglob
--
Stéphane
|
|
|
|