## stripping the last line

### stripping the last line

Hello all.  This is probably a FAQ, but I just read through the
seven-part FAQ recently posted, and couldn't find the answer, so here goes:

I have a file of statistics, and the last line is not significant and I
wish to discard it, as more data will be appended to the file daily and I
want a certain purity of data. :)

Is there a *simple* way of stripping the last line off a file, or,
failing this, is there a *not so simple* way?

Your help will be most appreciated.
Simon Galton
--
||| | || || Generic Sig                                         ''`
||| | || || ===========                                         O-O
||| | || ||                                                      L

|| 01416 || Information Technology Dept, Sheridan College, Oakville, ON, Canada

### stripping the last line

| I have a file of statistics, and the last line is not significant and I
| wish to discard it, as more data will be appended to the file daily and I
| want a certain purity of data. :)
|
| Is there a *simple* way of stripping the last line off a file, or,
| failing this, is there a *not so simple* way?

sed '$d' inputfile > outputfile or, to do it without renaming, ed - file << \end_ed$d
w
q
ended

### stripping the last line

sed '\$d' filename > /tmp/filename; mv /tmp/filename filename

or you could write a C program to truncate the file in situ, but
this seems like overkill. (an ed script might also do this for you).

cheers

andrew

Help me to find a program stripping the -n first or last lines from a