less命令

时间:2020-02-23 14:45:00  来源:igfitidea点击:

less命令是一个用于查看文本文件内容的程序。
按照较少的手册,较少的程序类似于较大的程序,但是它允许在文件中向前和向后移动,并且在启动之前不读取整个输入文件,因此对于较大的输入文件,其速度比诸如vi的文本编辑器快。

less程序是more程序的替代。
它以逐页的方式显示文件的内容,因此属于寻呼机程序类别。

[theitroad@linux ~]$less filename

Example

[theitroad@linux ~]$less hello.txt

line 1
This is line number 2.
3rd Line
Line Number 4
Line 5
6th Line
hello.txt (END)

在终端中使用less命令的文件内容。

如何退出less?

我们使用q键少退出。

常用的less命令

CommandDescription
Up ArrowScroll up one line
Down ArrowScroll down one line
bScroll back one page
SpaceScroll forward one page
1GMove to the beginning of the text file
gMove to the beginning of the text file
GMove to the end of the text file
/charactersSearch for the next occurrence of the characters
nSearch for the next occurrence of the previous search
hDisplay help
qQuit less