To show the first 10 or 20 lines of a file in a Unix or Linux shell, you can use the head
command.
The head
command displays the first n
lines of a file, where n
is the number of lines to display. By default, head
displays the first 10 lines of a file.
To display a different number of lines, you can use the -n
option followed by the number of lines to display. For example, to display the first 20 lines of a file, you can use the following command:
head -n 20 file.txt
This will display the first 20 lines of the file.txt
file.
You can also use the -c
option followed by the number of bytes to display, rather than the number of lines. For example, to display the first 100 bytes of a file, you can use the following command:
head -c 100 file.txt
This will display the first 100 bytes of the file.txt
file.
It is important to note that the head
command displays the entire file if the file is smaller than the specified number of lines or bytes.
For more information about the head
command and its options, you can consult the documentation for your specific Unix or Linux system.