Use of the head -n command
The head command is used to display the contents of the beginning of the file. By default, the head command displays the first 10 lines of a file.
grammar
head(options)(parameters)
Options
-n<number>: Specify the number of lines to display the header content; -c<number of characters>: Specify the number of characters to display the header content; -v: always display the header information of the file name; -q: Do not display header information for filenames.
parameter
file list: Specifies the list of files to display the header content.
---------------------------------------------------------------------------------------------------
Linux command: detailed explanation of tail command
Overview: The tail command displays the block at the end of the file, and you can also view the online log
1. Format
tail [parameter] [file]
2. Parameters
-f loop read
-q do not display processing information
-v display detailed processing information
-c <number> number of bytes to display
-n<number of lines> Display the number of lines
3. Examples
#Create file tail.txt cat > tail.txt<<EOF 1 2 3 4 5 6 7 8 9 10 11 12 EOF
#Display last 5 lines tail-n 5 tail.txt
#display last 5 bytes tail -c 5 tail.txt
#loop through tail -f tail.txt
Overview: The tail command displays the block at the end of the file, and you can also view the online log
1. Format
tail [parameter] [file]
2. Parameters
-f loop read
-q do not display processing information
-v display detailed processing information
-c <number> number of bytes to display
-n<number of lines> Display the number of lines
3. Examples
#Create file tail.txt cat > tail.txt<<EOF 1 2 3 4 5 6 7 8 9 10 11 12 EOF
#Display last 5 lines tail-n 5 tail.txt
#display last 5 bytes tail -c 5 tail.txt
#loop through tail -f tail.txt