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 Systems Administration
Licenses BSD Revised
Operating Systems POSIX
Implementation Perl
Translations English

Tweet this project Short link

Rss Recent releases

  • Rrelease-mid
  •  19 Sep 2004 12:58
  • Rrelease-after

Changes: 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

Rcomment-before 19 Sep 2004 13:08 Rcomment-trans elroy31337 Rcomment-after

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`

Rcomment-before 26 May 2004 06:19 Rcomment-trans rodlima Rcomment-after

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!

Rcomment-before 21 May 2004 06:22 Rcomment-trans the_trapper Rcomment-after

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.

Rcomment-before 20 May 2004 14:14 Rcomment-trans bobBillll Rcomment-after

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.

Rcomment-before 20 May 2004 09:35 Rcomment-trans rodlima Rcomment-after

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.

No-screenshot

Project Spotlight

Groogle

A Web-based peer code review tool.

No-screenshot

Project Spotlight

php ban and trap

A Web site ban system.