Thursday, September 18, 2008

Delete all except one

How to delete all file except file(s) ...

> ls
1 2 3 4 5 6 7
>

I want to delete files 3, 4, 5, 6, 7 except 1 & 2
> rm `ls * | egrep -v "1|2"`
> ls
1 2
>

No comments:

Post a Comment