I am trying to read the last two lines of a file in an array of length two.
Consider the file a.txt
bar
second line
hello world
foo bar fubar
I tried
lines=($(tail -n 2 a.txt))
but this results in an array of length 5, each containing a single word. I read the post Creating an array from a text file in Bash but fail to go from there to reading only the last two lines. Please note that efficiency (execution time) matters for my needs.
I am on Mac OS X using Terminal 2.6.1