How to read only the second last line of a file
How about tail -n2 myfile.csv | head -n1 | awk ....
?
sed 'x;$!d' <infile
That should work for you.
Explanation:
On each line sed
ex
changes buffers (swaps contents of hold space and pattern space) and, if not on the last line, it d
eletes the current pattern space (so nothing gets printed). Only on the last line sed
autoprints the pattern space (which contains the previous line, i.e. second to last one)