The way to display a specific number of lines at the beginning of a file using `head`?

Published on Aug. 22, 2023, 12:20 p.m.

To display a specific number of lines at the beginning of a file using head, you can use the -n flag followed by the number of lines you want to display. Here is an example:

head -n 10 file.txt

This will display the first 10 lines of the file file.txt.

If you want to display the first portion of the file in bytes instead of lines, you can use the -c flag. For example:

head -c 100 file.txt

This will display the first 100 bytes of the file file.txt.

Note that head is a powerful command with many other options that can help you customize the output in various ways. Be sure to check out the man page for head for more information on how to use it.

Tags:

related content