One ,cat command

explain : This command displays all logs , If the file is large , Not recommended
cat business.log
 

Two ,more command

explain : Search the log for everything , And cat The difference is that ,more Commands are displayed page by page , By pressing the blank key space It's on the next page , Press b The key will go back one page .
more business.log
Three ,tail command

explain : Used to output the end of the file , You can also view the log in real time .
tail -f business.log # View the latest log output in real time tail -5f business.log # View the last output 5 Line log # Exit view :
Ctrl + C
Four ,grep command

explain :grep Command is a powerful text search tool , It can search text using regular expressions , And put the piece together The matching lines are printed out . 

grep The full name is Global Regular Expression Print, Represents the global regular expression version , Its permission is for all users .

Commonly used grep command :
grep 'xxx' demo.log # lookup demo.log belt ‘xxx’ Log content of grep 'xxx' demo.log -c
# see demo.log Middle zone ‘xxx’ The number of lines of log content grep 'xxx' demo.log | grep 'yyy'
# see demo.log Existing belt ‘xxx’ With ‘yyy’ Log content of grep -v 'xxx' demo.log # see demo.log No ‘xxx’ Log content of
grep 'xxx' demo.log | grep -v 'yyy' # see demo.log belt 'xxx', But without it 'yyy' Log content of grep
'xxx\|yyy' demo.log or grep -E "xxx|yyy" demo.log # Inquiry band `xxx` or `yyy` Log content of
notes : For example, the log content of the query is very large , Through the cooperation more or less For pagination display ,  as well as : By adding at the end of the appeal order | more  or | less  that will do
grep 'xxx' demo.log | more grep 'xxx' demo.log | grep 'yyy' | less grep -v
'xxx' demo.log | more
Attached grep Complete solution of command :

grammar :
grep
[-abcEFGhHilLnqrsvVwxy][-A< Displays the number of columns >][-B< Displays the number of columns >][-C< Displays the number of columns >][-d< Move >][-e< Model style >][-f< Model document >][--help][ Model style ][ File or directory ...]
parameter :

* -a or --text : Don't ignore binary data .
* -A< Displays the number of rows > or --after-context=< Displays the number of rows > : Except for the columns that match the template style , And display what follows the line .
* -b or --byte-offset : Before displaying the line that matches the style , Indicates the number of the first character in the line .
* -B< Displays the number of rows > or --before-context=< Displays the number of rows > : Except that the line that matches the style is displayed , And display the content before the line .
* -c or --count : Calculates the number of columns that conform to the style .
* -C< Displays the number of rows > or --context=< Displays the number of rows > or -< Displays the number of rows > : Except that the line that matches the style is displayed , And the contents before and after the line are displayed .
* -d < action > or --directories=< action > : When you specify that you are looking for a directory rather than a file , This parameter is required , otherwise grep The command will return information and stop the action .
* -e< Model style > or --regexp=< Model style > : Specifies a string as the style to find the contents of the file .
* -E or --extended-regexp : Use the style as an extended normal representation .
* -f< Rule file > or --file=< Rule file > :
Specify rule file , Its content contains one or more rule styles , Give Way grep Find file contents that meet the criteria of the rule , The format is one rule style per line .
* -F or --fixed-regexp : List of styles as fixed strings .
* -G or --basic-regexp : Use styles as normal representations .
* -h or --no-filename : Before displaying the line that matches the style , Does not indicate the file name to which the line belongs .
* -H or --with-filename : Before displaying the line that matches the style , Represents the file name to which the line belongs .
* -i or --ignore-case : Ignore character case differences .
* -l or --file-with-matches : Lists the file names whose contents match the specified style .
* -L or --files-without-match : Lists the names of files whose contents do not conform to the specified style .
* -n or --line-number : Before displaying the line that matches the style , Indicates the number of columns in the row .
* -o or --only-matching : Show only matches PATTERN part .
* -q or --quiet or --silent : No information is displayed .
* -r or --recursive : The effect and specification of this parameter "-d recurse" The parameters are the same .
* -s or --no-messages : No error messages are displayed .
* -v or --revert-match : Displays all lines that do not contain matching text .
* -V or --version : display version information .
* -w or --word-regexp : Show only columns that match the whole word .
* -x --line-regexp : Show only the columns that all columns match .
* -y : The effect and specification of this parameter "-i" The parameters are the same .
 

 

 

 

 

 

Technology