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.
Scan the code to follow the official account
Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge