less命令

less命令的作用与more相似,都可以用来浏览文件的内容,用less命令显示文件时,使用pageup键向上翻页,使用pagedown键向下翻页,使用按行浏览,使用q退出浏览,less在加载时不必读整个文件,加载速度会比more更快,less退出后shell不会留下刚显示的内容,而more退出后会在shell上留下刚显示的内容。

语法

less [option] [file]

参数

常用操作

示例

浏览file.txt文件。

less file.txt

ps查看进程信息并通过less分页显示。

ps -ef | less

查看file.txt文件并检索向后检索1字符串。

less file.txt 
/1

参考

https://man.linuxde.net/less
https://www.runoob.com/linux/linux-comm-less.html
https://www.tutorialspoint.com/unix_commands/less.htm