The first type: view the log of real-time changes
tail -f file name (the last 10 lines are the default, which is equivalent to increasing the parameter -n 10)
ctrl + c is to exit the tail command
Other situations:
tail -n 20 filename (display the last 20 lines of filename)
tail -n +5 filename (display the file starting from line 5)
The second type: search for logs near keywords
cat -n filename |grep "keyword"
Other situations:
cat filename | grep -C 5'keyword' (display the line that matches the string in the log and the 5 lines before and after it)
cat filename | grep -B 5'keyword' (display the matching string and the first 5 lines)
cat filename | grep -A 5'keyword' (display the matching string and the last 5)
The third type: enter the edit search: vi (vim)
1. Enter vim editing mode: vim filename
2. Enter "/keyword" and press enter to search
3. To find the next one, press "n"
Exit: After pressing the ESC key, then enter the: number, vi will wait for us to enter the command at the bottom of the screen
wq! Save and exit;
q! Exit without saving;
Other situations:
/Keyword Note: For forward search, press the n key to move the cursor to the next qualified place
?Keyword Note: Reverse search, press shift+n to move the cursor to the next qualified