Can I use tail with multiple files?

0752

Yes, you can use the tail command with multiple files. When you specify multiple files, tail will display the last lines of each file, separating the output for each file with a header indicating the file name.

For example, to display the last 10 lines of multiple files, you can use:

tail file1.txt file2.txt

If you want to specify a different number of lines for each file, you can use the -n option along with the file names:

tail -n 5 file1.txt -n 10 file2.txt

However, note that the above command will not work as intended because -n applies to the first file only. Instead, you can run separate tail commands for each file:

tail -n 5 file1.txt
tail -n 10 file2.txt

This way, you can effectively view the last lines of multiple files.

0 Comments

no data
Be the first to share your comment!