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 |
- All comments
Recent commentsRe: 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`
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!
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.
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.
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.