perl -ne 'print unless eof' file
Or with some head implementations:
head -n -1 file
Or:
sed '$d' file
Outputs the contents of the file except the last line (with for the latter variation in behaviour between sed implementations if that last line is not delimited or the input contains NUL bytes or sequences of bytes that can't be decoded into characters in the user's locale or overlong lines).
With perl and some sed implementations, you can add a -i option (or -i '' in some sed implementations) for the file to be edited in-place, but what happens then is that it creates a new file with that same output as contents to replace the original file.
To remove the last line of a file and modify it in place, it should be enough to truncate it just after the newline character that precedes that line.
On a GNU system, that can be done with:
n=1 file=path/to/some/file
truncate -s "-$(tail -n "$n" < "$file" | wc -c)" -- "$file"
Which truncates $file by an amount that corresponds to the length in bytes of the last $n lines.
tail does not read the full file contents, it just seeks to the end and reads backward until it finds the start of those $n lines, so even on a 5TiB file, as long as lines are not overly long, that will be close to instantaneous, while perl -i or sed -i would need to write 5TiB worth of extra data to disk.
The ksh93 shell has builtin seek (<#((offset))) and truncate (<>;) operators, so with that shell, you can also do:
0<>; "$file" <#(( EOF - ${ tail -n "$n" < "$file" | wc -c; } ))
Where 0<>; "$file" opens $file in read+write mode (like in Bourne's <> direction operator) but with truncation at current offset at the end (if the command being redirected is successful, but here there's no command), and <#(( EOF - offset )) seeks to an offset relative to the end (EOF). ${ ...; } is a form of command substitution that skips creating a subshell.
headandtailyou know of on different flavours?