To specify different numbers of lines for each file using the tail command, you will need to run separate tail commands for each file, as tail does not support specifying different line counts for multiple files in a single command.
Here’s how you can do it:
tail -n 5 file1.txt # Display the last 5 lines of file1.txt
tail -n 10 file2.txt # Display the last 10 lines of file2.txt
tail -n 3 file3.txt # Display the last 3 lines of file3.txt
If you want to combine the output into a single command line, you can use a subshell or a script. Here’s an example using a subshell:
{
tail -n 5 file1.txt
echo
tail -n 10 file2.txt
echo
tail -n 3 file3.txt
}
This will display the specified number of lines for each file in sequence, with a blank line in between the outputs for clarity.
