Can `tail` show multiple files?

0174

Yes, the tail command can display the contents of multiple files simultaneously. When you specify multiple files as arguments, tail will show the last few lines of each file in the order they are provided. It will also prepend each output section with the file name for clarity.

Example Usage

To view the last 10 lines of multiple files, you can use the following command:

tail file1.txt file2.txt

This command will output the last 10 lines of file1.txt followed by the last 10 lines of file2.txt.

Customizing Output

You can also customize the number of lines displayed for each file using the -n option:

tail -n 5 file1.txt file2.txt

This will show the last 5 lines of both file1.txt and file2.txt.

Example Scenario

If you have two log files, error.log and access.log, and you want to quickly check the most recent entries in both, you can run:

tail error.log access.log

The output will clearly indicate which lines belong to which file.

Conclusion

Using tail with multiple files is a convenient way to monitor and compare the end portions of several files at once. If you have any further questions or need more examples, feel free to ask!

0 Comments

no data
Be the first to share your comment!