less命令查看 log 文件
less file.log (打开了文件从第一行开始,若想移到最后一行 shift+g ctrl+b往前一页一页翻页查看)
j - 向前移动一行
k - 向后移动一行
G - 移动到最后一行
g - 移动到第一行
ctrl + F - 向前移动一屏
ctrl + B - 向后移动一屏
less file.log (打开了文件从第一行开始,若想移到最后一行 shift+g ctrl+b往前一页一页翻页查看)
j - 向前移动一行
k - 向后移动一行
G - 移动到最后一行
g - 移动到第一行
ctrl + F - 向前移动一屏
ctrl + B - 向后移动一屏
q / ZZ - 退出 less 命令
模仿 tail -f Press F
向下10行 10j – 10
向上10行 10k
- CTRL+G – show the current file name along with line, byte and percentage statistics.
-
Less Command – Multiple file paging
Method 1: You can open multiple files by passing the file names as arguments.
$ less file1 file2
Method 2: While you are viewing file1, use :e to open the file2 as shown below.
$ less file1 :e file2
Navigation across files: When you opened more than two files ( for e.g – less * ), use the following keys to navigate between files.
- :n – go to the next file.
- :p – go to the previous file.
示例
查看命令历史使用记录并通过less分页显示
命令:
history | less