How to get the last line of a file using cat command How to get the last line of a file using cat command unix unix

How to get the last line of a file using cat command


Don't use cat. tail was meant for this usecase exactly:

$ tail -1 ./test.properties


Don't have enough reputation to comment Mureinik's post to answer your last question, but if you want to display a part of a file between known lines, you can try sed -n '<line1>,<line2>p <filename>.

If you don't know the lines, mix tail and sed : For your file :

tail -r test.properties | sed -n '2p'