1. Cat command:
function:1) Displays the entire file.
Demo Sample: $ cat FileName
2) Connect the file string to the basic output, such as merging several files into one file or output to the screen.
Demo Sample: $ cat file1 file2 > file
Description: Connect the file string to the basic output (screen or add > FileName to a file)
Cat references are explained in detail:
-N or –number numbering of all output lines starting from 1
-B or –number-nonblank and-n are similar. Just for blank lines not numbered
-S or –squeeze-blank when a blank line is encountered with more than two lines in succession. A blank line that is substituted as a line
-V or –show-nonprinting
2. More Commands:
View the log as a percentage.
3. Less command:
Almost the same as the more features. Just less support to flip through the files before and after.
4. Head command:
function: from the head of a text file, the Head command is used to view the beginning of a text file.
The scale is as follows:
Head Example.txt Displays the first 10 lines of the file example.txt;
Head-n Example.txt Display the first 20 lines of the file example.txt;
Head Specific explanation:
-n Specifies how many lines of text you want to display.
-N Number This option must be a decimal integer. It will determine the position in the file in order to behave in units.
The-c number, which must be a decimal integer, determines the position in the file, in bytes.
5. Tail Command:
function:the tail command is used to display the end lines of a text file.
The scale is as follows:
Tail Example.txt Display the following 10 lines of the file example.txt;
Tail-n example.txt Display the file example.txt the following 20 lines of content;
Tail-f Example.txt Displays the following 10 lines of file Example.txt and after the file contents have been added. Self-actively display the new file content.
Tail-n 50-f example.txt Display the file example.txt the following 50 lines of content and after the contents of the file is added, you actively display the new file content.
Attention:
The last command is useful, especially when monitoring log files to keep the new log information displayed on the screen.
Tail Specific Explanation:
-B number starts reading the specified file from the 512-byte block position represented by the number variable.
-C number starts reading the specified file from the byte position represented by the number variable.
-F assumes that the input file is a regular file or assumes that the file parameter specifies a FIFO (first in and out),
Then the tail command will not terminate after the last specified unit of the input file has been copied, but continue
Read and copy additional units from the input file (when these units are available).
If you do not specify a File parameter,
And the standard input is a pipe, the-f flag is ignored.
The tail-f command can be used to monitor the growth of a file that is also being written by a process.
-K number starts reading the specified file from the 1KB block position represented by the number variable.
-m number starts reading the specified file from the multibyte character position represented by the # variable. Use this flag to provide consistent results in a single-byte and double-byte character code set environment.
-N number reads the specified file from the first or last row position. The position is represented by the sign of the number variable (+ or-or none), and is shifted by the Line No.
-R Displays the output in reverse order from the end of the file. The default value of the-R flag is to display the entire file in reverse order.
Assuming that the file is larger than 20,480 bytes, the-R flag only shows the last 20,480 bytes. The-R flag has only
is valid with the-n flag. Otherwise, it will be ignored.
View Log basic commands under Linux