[nylug-talk] logrotate question
N.J. Thomas
njt at ayvali.org
Sat Feb 2 17:49:59 EST 2008
* Kristian Erik Hermansen <kristian.hermansen at gmail.com> [2008-02-02 14:24:19-0800]:
> > ls foo.*gz|head -n -5|xargs rm -f
> >
> > (You need GNU head for this to work. Try ghead(1) if you are on a
> > BSD box. But then, you probably don't care about that since you are
> > reading this on NYLUG.)
>
> No, that's totally wrong dude!
Why do you say that?
OP just wanted to delete files given a list of files, and keep the last
N. Their logrotate question was just a red herring because according to
the shell script they posted, they just wanted to delete files, not
rotate them out of the way or anything.
I suppose I should have put a sort in there, like this:
ls foo.*gz|sort|head -n -5|xargs rm -f
because I'm never quite sure if ls/find sorts output properly or not.
But why do you say that this solution is wrong?
Thomas
--
N.J. Thomas
njt at ayvali.org
Etiamsi occiderit me, in ipso sperabo
More information about the nylug-talk
mailing list