[X-Unix] Remove last ten lines of files
Stroller
MacMonster at myrealbox.com
Fri Jan 2 04:35:35 PST 2004
On Jan 2, 2004, at 11:04 am, Kuestner, Bjoern wrote:
> 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".
> ...
> Next I considered what I know about sed and grep.
> Again nothing for the task.
> ...Eventually this script or command should be placed into a postfix
> configuration to treat specific mail signatures.
I'm pretty sure this can be done using `sed`, but my research his
morning indicates it's tricky. Because `sed` is a stream-editor, it
doesn't normally know ahead of time where the end-of-file is. For this
reason you have, I think, to use the placeholder function.
My Linux box seems to have a better `info sed` than my Mac (Panther);
it gives the following examples, apparently for emulating the `tail`
command:
#!/usr/bin/sed -nf
1! {; H; g; }
1,10 !s/[^\n]*\n//
$p
h
The full page is available here
<http://www.delorie.com/gnu/docs/sed/sed_26.html> - you may find the
2nd example useful, also.
My question is: do you REALLY want to do this..? If the emails you're
transforming are, say, from a mailing list for personal use, then all
well & good, however if the signatures you're removing are from
corporate emails, then their removal may be questionable. Should the
emails ever be used in a legal framework then they may be dismissed
because they have been manipulated, even if it is not your intent to
edit their main content.
Stroller.
More information about the X-Unix
mailing list