Remove last ten lines of files

Kuestner, Bjoern Bjoern.Kuestner at drkw.com
Fri Jan 2 03:04:08 PST 2004


Hi,

does anybody have a simple solution to remove the last ten lines of files
(of variable length).

An alternative solution would be to remove anything from a file that follows
a signal pattern like "CutHere".

I looked at tail -10 and tail +10.
The first returns the last ten lines, the latter all but the first ten
lines.

I looked at head -10 and head +10.
Both return the first ten lines.

None of these returned all but the last ten lines.

I then thought about using "wc -l".
But the output, e.g. "   68 test.txt" does not allow arithmetic
interpretation.

Next I considered what I know about sed and grep.
Again nothing for the task.

I am not familiar with Perl, although a Perl solution would be acceptable.

Do I really have to build a long script for this seemingly simple task?

Thanks and regards,

Bjorn


======================================

.


--------------------------------------------------------------------------------
The information contained herein is confidential and is intended solely for the
addressee. Access by any other party is unauthorised without the express 
written permission of the sender. If you are not the intended recipient, please 
contact the sender either via the company switchboard on +44 (0)20 7623 8000, or
via e-mail return. If you have received this e-mail in error or wish to read our
e-mail disclaimer statement and monitoring policy, please refer to 
http://www.drkw.com/disc/email/ or contact the sender.
--------------------------------------------------------------------------------



More information about the X-Unix mailing list