How to join files using 'tail' command while displaying limited lines

0

I have multiple log files and I want to display its joint output. One way of doing this is by executing this command:

tail file-1 file-2

But I also want to display only a specific number of lines and if I include the number of lines parameter in this command like this:

tail -n file-1 file-2

OR

tail -n file-1 -n file-2

It says tail: option used in invalid context

So how do I do this?

Punit Naik

Posted 2016-01-12T05:57:28.287

Reputation: 113

Answers

0

Add number of lines to your tail command:

tail -n 10 file-1 -n 10 file-2

Cyrus

Posted 2016-01-12T05:57:28.287

Reputation: 4 356

Slight rectification in your command: tail -n x-lines file-1 -n y-lines file-2 – Punit Naik – 2016-01-12T07:29:21.307

0

Use the shell to repeat a command for each file -

for each in file-1 file-2; do tail -X $each; done

Or, if the files are all of the same type

find . -type f -name "namespec" -exec tail -X {} \;

davidgo

Posted 2016-01-12T05:57:28.287

Reputation: 49 152