Remove Last Line Of File

Hi Experts

I've a 10Gb UNIX text file and I need to remove the very last line.
Can anyone help me out?
stummjAsked:
Who is Participating?
 
ravenplCommented:
head -n -1 filename > new.filename # would also do with less memory consumption, but will create new file.

0
 
ozoCommented:
perl -MTie::File -e 'tie @array, 'Tie::File', shift or die $!; pop @array; untie @array' file
0
 
stummjAuthor Commented:
Cool - but whats the syntax I need to use? which bits do I need to replace with my filename and do I need a redirect to a new file or will it just strip off the last line in the existing file?
0
 
stummjAuthor Commented:
Great! That will do nicely thanks.
0
 
ravenplCommented:
But do try ozo's sollution - it's inplace sollution, hence may be better.
perl -MTie::File -e 'tie @array, 'Tie::File', shift or die $!; pop @array; untie @array' FILENAME_HERE
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.