How do I get the last non-empty line of a file using tail in Bash?
Posted
by debugger
on Stack Overflow
See other posts from Stack Overflow
or by debugger
Published on 2010-04-14T15:52:08Z
Indexed on
2010/04/14
16:03 UTC
Read the original article
Hit count: 167
How do I get the last non-empty line using tail
under Bash shell?
For example, my_file.txt
looks like this:
hello
hola
bonjour
(empty line)
(empty line)
Obviously, if I do tail -n 1 my_file.txt
I will get an empty line. In my case I want to get bonjour
. How do I do that?
© Stack Overflow or respective owner