Focus on cloud service provider activities
Notes on website operation and maintenance

Linux head command usage details and common cases

The head command is used to display the beginning of the file. By default, the first 10 lines of the file will be displayed. It is very common in Linux and other Unix like systems. In this article, Lao Zuo plans to organize the usage and cases of the head command in detail.

1. Usage

 Head [option] [filename]

2. Common Options

 -N<Number of lines>or -- lines=<Number of lines>: specify the number of lines to display. -C<Number of bytes>or -- bytes=<Number of bytes>: specify the number of bytes to display. -Q or -- quiet: Do not display the file name. -V or -- verbose: Displays the file name. -Z or -- zero terminated: Use zero character ( 0) as the line separator. -F or -- follow: track file changes and continuously output new content.

3. Example

Display the first 10 lines of the file:

 head filename

Display the first 20 lines of the file:

 head -n 20 filename

Display the first 100 bytes of the file:

 head -c 100 filename

Do not display the file name, only display the content:

 head -q filename

Display file name and content:

 head -v filename

Track file changes and continuously output new content:

 head -f filename

Summary, The head command can easily view the beginning of the file. Different options can flexibly control the number of lines or bytes displayed and whether to display the file name.

Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Linux head command usage details and common cases


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge