Command to view the specified number of lines in the file
tail command (to view the data at the end of the file)
1 #The content at the end of the output file, 10 lines by default
2 tail date.log
3
4 # Output the content of the last 20 lines
5 tail -20 date.log
6
7 # Output from the 20th line from the bottom to the end of the file
8 tail -n -20 date.log
9
10
11 # Output from line 20 to the end of the file
12 tail -n +20 date.log
13
14 # The content of the real-time monitoring file is increased, and the default is 10 lines.
15 tail -f date.log
head command (view the beginning of the file)
1 #Output the content at the beginning of the file, 10 lines by default
2 head date.log
3
4 # Output the content of the first 15 lines
5 head -15 date.log
6
7 # Output the content from the beginning to the 15th line
8 head -n +15 date.log
9
10 # Output the content from the beginning to the 15th line from the bottom
11 head -n -15 date.log
sed command< /h2>
1 # sed -n'start line, end line p'file name
2
3 # Output the content from line 70 to line 75
4 sed -n ‘70,75p‘ date.log
5
6 # Output line 6 and lines 260 to 400
7 sed -n ‘6p;260,400p; ‘file name
8
9 # Output line 5
10 sed -n 5p file name
Find the contents of the file according to the field
1 # sed -n'start line, end line p'file name
2
3 # Output the content from line 70 to line 75
4 sed -n ‘70,75p‘ date.log
5
6 # Output line 6 and lines 260 to 400
7 sed -n ‘6p;260,400p; ‘file name
8
9 # Output line 5
10 sed -n 5p file name
< h2>grep command
grep " is Search string" filename
1 #The content at the end of the output file, default 10 lines< /span>
2 tail date.log
3
4 # Output the content of the last 20 lines
5 tail -20 date.log
6
7 # Output from the 20th line from the bottom to the end of the file
8 tail -n -20 date.log
9
10
11 # Output from line 20 to the end of the file
12 tail -n +20 date.log
13
14 # The content of the real-time monitoring file is increased, and the default is 10 lines.
15 tail -f date.log
1 #Output the content at the beginning of the file, 10 lines by default
2 head date.log
3
4 # Output the content of the first 15 lines
5 head -15 date.log
6
7 # Output the content from the beginning to the 15th line
8 head -n +15 date.log
9
10 # Output the content from the beginning to the 15th line from the bottom
11 head -n -15 date.log
1 # sed -n'start line, end line p' File name
2
3 # Output the content from line 70 to line 75
4 sed -n ‘70,75p‘ date.log
5
6 # Output line 6 and lines 260 to 400
7 sed -n ‘6p;260,400p; ‘file name
8
9 # Output line 5
10 sed -n 5p file name
grep "the string being searched" filename pre>