Editing the end of the file without loading the entire file

hi! I am a newbee. I would really appreciate if you can answer the following question:

I have a huge data file, 214MB with several coloumns. I need to delete the very last line of the file. Everything I know takes a lot of time to do it ( because I have to open the file in an editor or run a script in awk or something).

Does anybody know of a really quick way to accomplish this?

I am using Solaris 9.

Thanks.

If the file has carriage control - ie., it's a text file this may help:

#!/bin/ksh -v
# parameters old file = $1
#            new file = $2
# I know this first line is slow... but you need the total
lines=`cat $1 | wc -l`
let lines=lines-1
head -n $lines  $1 > $2

The whole point is to avoid reading the entire file even once. So even something like
sed '$d' <old > new
is too much.

I just ran a small awk script to accomplish what I needed to do, but I wanted to find out if there was a much better way to do it for next time.

Driver, thanks for the program. I was looking for someway to access the file from the end ( essentially what your last for loop does), but just from the shell ( instead of writing a program).

I like Jim's solution, but yes wc -l takes some time. I dont know sed yet, but I am learning it.

Thanks everybody.