Projects / Keep

Keep

keep is a program which deletes everything in a directory except for the files that you tell it to keep. It is useful in the situation where the list of files in a directory that you want to keep is shorter than the list of files you want to delete.

Tags
Licenses
Operating Systems
Implementation
Translations

RSS Recent releases

  •  19 Sep 2004 12:58

Release Notes: Running keep without arguments now displays a brief help message. This change was made in order to make it behave more like a traditional Unix command.

No changes have been submitted for this release.

RSS Recent comments

19 Sep 2004 13:08 niggerbottom

Re: Other way to do it

>

> % Hi, well, maybe you already know

> this,

> % but under bash with the extglob shell

> % option enabled, you can do this:

> %

> % rm !(file1 file2)

> %

> % to remove everything but file1 and

> % file2.

>

>

>

> Or even,

>

> ls | egrep -v '(REGEXP1|REGEXP2|...)' |

> xargs rm # in most any shell

>

> ...without digging through the manpage,

> I'm certain `find' could also be coaxed

> into doing something like this as

> well.

>

alternatively:

rm `/bin/ls | grep -v PATTERN`

26 May 2004 06:19 rodlima

Re: Other way to do it

> That's what I love about UNIX...so many

> different ways to do things! :-)

>

> Anyway...I'll keep working on this and

> make it even more powerful.

>

"so many different ways to do things"... it sounds scary to me :) but good luck then!

21 May 2004 06:22 the_trapper

Re: Other way to do it

> Hi, well, maybe you already know this,

> but under bash with the extglob shell

> option enabled, you can do this:

>

> rm !(file1 file2)

>

> to remove everything but file1 and

> file2.

Thanks, actually I didn't know this. I think you would agree that Keep is a little more "user friendly" than this, however.

That's what I love about UNIX...so many different ways to do things! :-)

Anyway...I'll keep working on this and make it even more powerful.

20 May 2004 14:14 bobBillll

Re: Other way to do it

> Hi, well, maybe you already know this,

> but under bash with the extglob shell

> option enabled, you can do this:

>

> rm !(file1 file2)

>

> to remove everything but file1 and

> file2.

Or even,

ls | egrep -v '(REGEXP1|REGEXP2|...)' | xargs rm # in most any shell

...without digging through the manpage, I'm certain `find' could also be coaxed into doing something like this as well.

20 May 2004 09:35 rodlima

Other way to do it
Hi, well, maybe you already know this, but under bash with the extglob shell option enabled, you can do this:

rm !(file1 file2)

to remove everything but file1 and file2.

Screenshot

Project Spotlight

Blink

A small open blog engine.

Screenshot

Project Spotlight

Arcueid

A C interpreter for Arc, Paul Graham's dialect of Lisp.