Can it show multiple files?

097

Yes, the head command can display the beginning of multiple files at once. When you specify multiple files, head will show the first few lines of each file, separating the output for each file with a header indicating the file name.

Here’s how you can use it:

head file1.txt file2.txt file3.txt

In this example, head will display the first 10 lines of file1.txt, followed by the first 10 lines of file2.txt, and then the first 10 lines of file3.txt. If you want to specify a different number of lines for each file, you can use the -n option:

head -n 5 file1.txt file2.txt

This command will show the first 5 lines of file1.txt and the first 5 lines of file2.txt.

0 Comments

no data
Be the first to share your comment!