less命令的作用与more十分相似,都可以用来浏览文字档案的内容,不同的是less命令允许用户向前或向后浏览文件,而more命令只能向前浏览。

用less命令显示文件时,用PageUp键向上翻页,用PageDown键向下翻页。要退出less程序,应按Q键。

    (1)用法:

用法: less  [选项参数] [文件参数]

    (2)功能:

功能: less 与more命令类似,但可以通过翻页键查看上下页的内容

    (3)选项参数:

    1) -e:                                               文件内容显示完毕后,自动退出

2) -f:                                                强制显示文件

  3) -g:                                               不加亮显示搜索到的所有关键词,仅显示当前显示的关键字,以提高显示速度

  4) -l:                                                搜索时忽略大小写的差异

  5) -N:                                               每一行行首显示行号

6) -s:                                               将连续多个空行压缩成一行显示

  7) -S:                                               在单行显示较长的内容,而不换行显示

  8) -x<数字>:                                     将TAB字符显示为指定个数的空格字符。

    (4)实例:

1)[root@localhost Documents]# less  less_text                  在另一个进程页面中显示文本内容,按q键退出

[root@localhost Documents]# mv more_text1 less_text    //将more_text1改名为less_text
[root@localhost Documents]# ll
总用量
-rw-r--r--. root root 5月 : less_text
[root@localhost Documents]# cat less_text //在当前终端中显示(和less命令显示的效果还是有差别的)
[root@localhost Documents]# less less_text   //在另一个页面中显示文本
I am studing orders of Linux!
I am trying to write as many as lines of text! No matter how low you consider yourself,
there is always someone looking behind you,
hoping that they were that high! Something you want keep all the time,always you will lose! Never forget to say "thanks"! Hppay today,also,prepared for happiness in the future! Don't aim your success if you want it,just do what you love and believe and finally you will success! Maybe you can be laze man like a pig,but you can't feel free as it! I am a college school student!
I am planning to live and work in hangzhou or guangzhou!
I am from hefei anhui!
Enough,I have write too many words!
(END)

2)[root@localhost Documents]# ps -ef |less      显示已有进程信息

ID         PID   PPID  C STIME TTY          TIME CMD
root : ? :: /usr/lib/systemd/systemd --switched-root --system --deserialize
root : ? :: [kthreadd]
root : ? :: [ksoftirqd/]
root : ? :: [kworker/:0H]
root : ? :: [migration/]
root : ? :: [rcu_bh]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
root : ? :: [rcuob/]
:
.......//还有很多没有显示

3)[root@localhost Documents]# history | less               显示历史输入的进程信息

      touch touch_test /home/sunjimeng/Document
cd /home/sunjimeng/Document
ll
cd /
touch touch_text /home/sunjimeng/Document/touch_test
cd /home/sunjimeng/Document
ll
rm touch_test
cd /
ls -l /home/sunjimeng/Document
touch /home/sunjimeng/Document/touch_test_file
cd home/sunjimeng/Document
ll
touch touch_test_file
ll
touch -t touch_test_file
ll
touch touch_test_file
ll
touch -t touch_test_file
ll
touch touch_test_file2
ll
touch -r touch_testfile touch_test_tile2
touch -r touch_test_file touch_test_file2
ll
touch -d "10 day ago" touch_test_file2
ll
touch -r touch_test_file touch_test_file2
ll
touch -d "10 days ago" touch_test_file2
ll
touch "10 days ago" touch_test_file
ll
:

4)[root@localhost Documents]# less less1 less2                          查看多个文件(怎么切换下一个还不清楚)

root@localhost Documents]# cat >less1 <<EOF
> Lost means Get!
>
> No losing No getting!
>
> End!
> EOF
[root@localhost Documents]# cat >less2 <<EOF
> If you want keep,you always lose!
>
> Certainly It is!
> End!
> EOF
[root@localhost Documents]# ll
总用量
-rw-r--r--. root root 5月 : less1
-rw-r--r--. root root 5月 : less2
-rw-r--r--. root root 5月 : less_text
[root@localhost Documents]# less less1 less2
Lost means Get!

No losing No getting!

End!
less1 (file 1 of 2) (END) - Next: less2

5)[sunjimeng@localhost ~]$ netstat -tpnl |less      在另一个进程页面中分页显示信息,这里显示的是网络信息

[sunjimeng@localhost ~]$ netstat -tpnl |less
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0.0.0.0: 0.0.0.0:* LISTEN -
tcp 127.0.0.1: 0.0.0.0:* LISTEN -
tcp 127.0.0.1: 0.0.0.0:* LISTEN -
tcp6 ::: :::* LISTEN -
tcp6 ::: :::* LISTEN -
tcp6 ::: :::* LISTEN -

    (5)其他:

  1.全屏导航

  ctrl + F - 向前移动一屏

  ctrl + B - 向后移动一屏

  ctrl + D - 向前移动半屏

  ctrl + U - 向后移动半屏

  2.单行导航

  j - 向前移动一行

  k - 向后移动一行

  3.其它导航

  G - 移动到最后一行

  g - 移动到第一行

  q / ZZ - 退出 less 命令

  4.其它有用的命令

  v - 使用配置的编辑器编辑当前文件

  h - 显示 less 的帮助文档

  &pattern - 仅显示匹配模式的行,而不是整个文件

  5.标记导航

  当使用 less 查看大文件时,可以在任何一个位置作标记,可以通过命令导航到标有特定标记的文本位置:

  ma - 使用 a 标记文本的当前位置

  'a - 导航到标记 a 处

每天一个Linux命令(13)less命令的更多相关文章

  1. 每天一个linux命令(13):less命令

    1.命令简介 less(less)  命令可以对文件或其它输出进行分页显示,与moe命令相似,但是比more命令要强大许多.应该说是linux正统查看文件内容的工具. 2.用法 less [选项].. ...

  2. linux常用命令(13)tail命令

    tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不但刷新, ...

  3. Linux经常使用的命令(必看)

    http://www.importnew.com/12425.html     http://www.importnew.com/13107.html http://www.importnew.com ...

  4. 每天一个Linux命令(13):apt命令

    apt-get和apt-cache命令是Debian Linux发行版中的APT软件包管理工具.所有基于Debian的发行都使用这个包管理系统.deb包可以把一个应用的文件包在一起,大体就如同Wind ...

  5. 每天一个linux命令:more(13)

    more more命令是一个基于vi编辑器文本过滤器,它以全屏幕的方式按页显示文本文件的内容,支持vi中的关键字定位操作.more名单中内置了若干快捷键,常用的有H(获得帮助信息),Enter(向下翻 ...

  6. 每天一个linux命令(13):more命令

    版权声明更新:2017-05-17博主:LuckyAlan联系:liuwenvip163@163.com声明:吃水不忘挖井人,转载请注明出处! 1 文章介绍 本文介绍了Linux下面的mv命令. 2. ...

  7. 【每天一个Linux命令】13. Linux中whereis命令的用法

      命令用途 whereis命令用来查找命令的位置,包括执行文件.源代码和手册页文件 命令用法 1. 查找指定命令<command>的位置,包括执行文件.源代码和手册页文件 格式:wher ...

  8. 每天一个 Linux 命令(21):find命令之xargs

    在使用 find命令的-exec选项处理匹配到的文件时, find命令将所有匹配到的文件一起传递给exec执行.但有些系统对能够传递给exec的命令长度有限制,这样在find命令运行几分钟之后,就会出 ...

  9. 每天一个linux命令(46):vmstat命令

    vmstat是Virtual Meomory Statistics(虚拟内存统计)的缩写,可对操作系统的虚拟内存.进程.CPU活动进行监控.他是对系统的整体情况进行统计,不足之处是无法对某个进程进行深 ...

  10. 每天一个linux命令目录

    出处:http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html 开始详细系统的学习linux常用命令,坚持每天一个命令,所以这个系列为每 ...

随机推荐

  1. Flex 自定义打印控件编写

    打印历来是web应用一个比较棘手的问题,幸好flex web应用是运行在flash player上的,flash player可以访问打印机,所以flex 应用可以实现比较强大的打印功能.Flex 自 ...

  2. 把质量控制工作往前推进(1)——安装sonarqube

    曾经关注点一直在怎么提高应用程序的质量,没太在意代码级别的质量.近期由于某些因素的推动,须要关注到代码级别的质量去,把质量工作尽量往前推,也符合质量控制的原则.  试用了一下sonarqube(老版本 ...

  3. 数据存储之iOS断点续传

    iOS里面实现断点续传 第三方框架之AFN 代码实现 一.iOS里面实现断点续传 1⃣️AFN基于NSURL 1.性能和稳定性略差.针对JSON.XML.Plist和Image四种数据结构封装了各自处 ...

  4. C++井字棋游戏,DOS界面版

    据说有一个能保证不败的算法.明天看看先再写个PVC版的. 正题.今天无聊写了个井字棋游戏,顺便逐渐让自己习惯良好的代码风格,放上来给新手学习学习. jzq2.cpp /* N字棋游戏PVP版,DOS版 ...

  5. Hibernate学习之单向多对一映射

    © 版权声明:本文为博主原创文章,转载请注明出处 说明:该实例是通过映射文件和注解两种方式实现的.可根据自己的需要选择合适的方式 实例: 1.项目结构 2.pom.xml <project xm ...

  6. Eclipse Plugin Installation and Windows User Access Control

    I make Eclipse Plugins and I sell them to developers using Eclipse. Most of the visitors to my web s ...

  7. Thread 常搞混的几个概念sleep、wait、yield、interrupt

    sleep:在指定的毫秒数内让当前正在执行的线程休眠(暂停执行),此操作受到系统计时器和调度程序精度和准确性的影响.该线程不丢失任何监视器的所属权. 通过调用sleep使任务进入休眠状态,在这种情况下 ...

  8. 基于java spring框架开发部标1078视频监控平台精华文章索引

    部标1078视频监控平台,是一个庞杂的工程,涵盖了多层协议,部标jt808,jt809,jt1078,苏标Adas协议等,多个平台功能标准,部标796标准,部标1077标准和苏标主动安全标准,视频方面 ...

  9. IIS中使用ASP.NET MVC的经验总结

    在这篇文章中我们学习在不同版本的IIS中使用ASP.NET MVC和URL Routing.我们学习针对IIS7.0.IIS6.0和更早版本的IIS的处理策略. ASP.NET MVC框架依赖于URL ...

  10. 出现windows启动服务失败(无法从命令行或调试器启动,需要安装InstallUtil.exe)的解决办法

    两种方法1 从命令行安装2 选择项目-视图-自定义操作   然后将 安装,提交,回滚,卸载分别加入自定义操作,注意InstallClass属性为true