How to tail the last line of multiple files using "tail -1 */filename"

mrkent picture mrkent · Apr 27, 2012 · Viewed 41.8k times · Source
tail */filename

works, but

tail -1 */filename

doesn't. Why is this? And is there a 1 liner to perform this task without loops?

head -1 */filename

works for some strange reason.

Answer

Casper picture Casper · Apr 27, 2012

While head works with -1 on multiple files, tail does not. But it works with the -n argument instead:

tail -n 1 */filename