linuxbashtailhead

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


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.


Solution

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

    tail -n 1 */filename