I had this question... answered and very nice it was too. But, oddity has emerged whereby if the log file has a unique last line, (i.e. the first few words are different to the preceeding lines) it correctly returns that last line with tail -n 1 "file"
but if the last few lines are similar to the the last line, it returns all the lines that are similar.
Let me show you....
The file it's reading is...
frame= 1065 fps= 30 q=1.6 size= 11977kB time=35.54 bitrate=2761.1kbits/s
frame= 1081 fps= 30 q=2.7 size= 12174kB time=36.07 bitrate=2765.0kbits/s
frame= 1097 fps= 30 q=2.7 size= 12332kB time=36.60 bitrate=2759.9kbits/s
frame= 1113 fps= 30 q=3.0 size= 12487kB time=37.14 bitrate=2754.4kbits/s
frame= 1129 fps= 30 q=2.4 size= 12652kB time=37.67 bitrate=2751.3kbits/s
frame= 1145 fps= 30 q=2.4 size= 12824kB time=38.20 bitrate=2749.7kbits/s
frame= 1161 fps= 30 q=2.4 size= 12996kB time=38.74 bitrate=2748.1kbits/s
frame= 1176 fps= 30 q=2.7 size= 13162kB time=39.24 bitrate=2747.8kbits/s
frame= 1191 fps= 30 q=2.6 size= 13328kB time=39.74 bitrate=2747.4kbits/s
frame= 1206 fps= 30 q=2.5 size= 13496kB time=40.24 bitrate=2747.5kbits/s
frame= 1222 fps= 30 q=2.5 size= 13685kB time=40.77 bitrate=2749.6kbits/s
frame= 1240 fps= 30 q=4.2 size= 13954kB time=41.38 bitrate=2762.8kbits/s
frame= 1261 fps= 31 q=4.6 Lsize= 14428kB time=42.08 bitrate=2809.1kbits/s
video:13889kB audio:494kB global headers:0kB muxing overhead 0.314239%
$line = `tail -n 1 "$logfile"`;
RETURNS...
video:13889kB audio:494kB global headers:0kB muxing overhead 0.314239%
However, if that last, more unique line, isn't there... it returns:-
frame= 1065 fps= 30 q=1.6 size= 11977kB time=35.54 bitrate=2761.1kbits/s
frame= 1081 fps= 30 q=2.7 size= 12174kB time=36.07 bitrate=2765.0kbits/s
frame= 1097 fps= 30 q=2.7 size= 12332kB time=36.60 bitrate=2759.9kbits/s
frame= 1113 fps= 30 q=3.0 size= 12487kB time=37.14 bitrate=2754.4kbits/s
frame= 1129 fps= 30 q=2.4 size= 12652kB time=37.67 bitrate=2751.3kbits/s
frame= 1145 fps= 30 q=2.4 size= 12824kB time=38.20 bitrate=2749.7kbits/s
frame= 1161 fps= 30 q=2.4 size= 12996kB time=38.74 bitrate=2748.1kbits/s
frame= 1176 fps= 30 q=2.7 size= 13162kB time=39.24 bitrate=2747.8kbits/s
frame= 1191 fps= 30 q=2.6 size= 13328kB time=39.74 bitrate=2747.4kbits/s
frame= 1206 fps= 30 q=2.5 size= 13496kB time=40.24 bitrate=2747.5kbits/s
frame= 1222 fps= 30 q=2.5 size= 13685kB time=40.77 bitrate=2749.6kbits/s
frame= 1240 fps= 30 q=4.2 size= 13954kB time=41.38 bitrate=2762.8kbits/s
frame= 1261 fps= 31 q=4.6 Lsize= 14428kB time=42.08 bitrate=2809.1kbits/s