Tail how to skip the last line

I am viewing a csv file and want to periodically write the last 5 lines of the file. Is there any way to do this by skipping the last line. for instance

I'm Polling File:

Fooo1,bar1,bar1
Fooo2,bar2,bar2
Fooo3,bar3,bar3
Fooo4,bar4,bar4
Fooo5,bar5,bar5
Fooo6,bar6,bar6
Fooo7,bar7,bar7

The tail command will only capture lines 2-6.

The problem is that the file continues to grow.

+4
source share
2 answers

I suggest you use this:

tail -5 file.csv | head -4
+3
source

Use this instead:

head -n -1 file.csv

This skips the last line explained here .

0
source

All Articles