How to customize line count?

To customize the number of lines displayed by the head command, you can use the -n option followed by the number of lines you want to see. Here’s how to do it:

Syntax

head -n [number_of_lines] [file_name]

Example

If you want to display the first 5 lines of a file named access.log, you would use the following command:

head -n 5 access.log

Output

This command will show the first 5 lines of access.log, allowing you to quickly review a smaller portion of the file.

Additional Notes

  • If you want to display all lines from the file, you can use head -n -0 [file_name], which effectively shows the entire file.
  • You can also use head [file_name] without the -n option to display the default 10 lines.

Feel free to try this out and let me know if you have any more questions!

0 Comments

no data
Be the first to share your comment!