Linux remove last line from file

In this article let’s discuss about Linux remove last line from file. Let’s go through the following methods without any delay.

Method 1:

sed '$d' 
sed -i '$d'  # to edit in place

If you are facing any issues with the above approach then try the alternative that is given below. It may look similar but have a try!

Method 2 :

# Basic syntax:
sed -i '$d' input_file

# Note, -i means that the input_file will be modified in place

Hope the above solution works.

Realted Posts : How to install git flow linux