Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 305
mrkent Avatar asked Apr 27 '12 15:04

mrkent


People also ask

How do you display the last line in a text file tail?

Use the tail command to write the file specified by the File parameter to standard output beginning at a specified point. This displays the last 10 lines of the accounts file. The tail command continues to display lines as they are added to the accounts file.

Can you tail multiple files?

MultiTail is an improvement on the well-known program tail, which allows you to view multiple files at the same time in the same window. a package for most distros, and you can also install it from source. Tip of the Trade: MultiTail makes it possible to watch two files simultaneously in real-time.

How do you end the tail command?

include ssh-api ssh = getSSHConnection(); cmd = 'cd to folder'; ssh. command(cmd); cmd = 'tail -f log. txt'; ssh. command(cmd); wait for special event to occur... cmd = 'stop the tail now!


1 Answers

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

tail -n 1 */filename
like image 78
Casper Avatar answered Sep 18 '22 08:09

Casper