zoukankan      html  css  js  c++  java
  • 【linux】文档查看

    cat:

    [root@localhost test]# cat log2013.log 
    2013-01
    2013-02
    2013-03
    [root@localhost test]# cat -n log2012.log #显示行号
         	1  2012-01
         	2  2012-02
    

    more:

    more命令,功能类似 cat ,cat命令是整个文件的内容从上到下显示在屏幕上。 more会以一页一页的显示方便使用者逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会往回(back)一页显示,而且还有搜寻字串的功能 。more命令从前向后读取文件,因此在启动时就加载整个文件。

    [root@localhost test]# cat log2012.log 
    2012-01
    2012-02
    2012-03
    2012-04-day1
    2012-04-day2
    2012-04-day3
    [root@localhost test]# more +3 log2012.log  #从第三行开始显示
    2012-03
    2012-04-day1
    2012-04-day2
    2012-04-day3
    [root@localhost test]#  ls -l  | more -5列一个目录下的文件,由于内容太多,我们应该学会用more来分页显示。
    总计 36
    -rw-r--r-- 1 root root  308 11-01 16:49 log2012.log
    -rw-r--r-- 1 root root   33 10-28 16:54 log2013.log
    -rw-r--r-- 1 root root  127 10-28 16:51 log2014.log
    lrwxrwxrwx 1 root root    7 10-28 15:18 log_link.log -> log.log
    -rw-r--r-- 1 root root   25 10-28 17:02 log.log
    

    head:

    [root@localhost test]# cat log2014.log 
    2014-01
    2014-02
    2014-03
    2014-04
    2014-05
    2014-06
    2014-07
    [root@localhost test]# head -n 5 log2014.log  ##显示前行5
    2014-01
    2014-02
    2014-03
    2014-04
    2014-05
    [root@localhost test]# head -c 20 log2014.log ##显示此文件前20个字节
    2014-01
    2014-02
    2014
    

    tail:

    [root@localhost test]# tail -n 5 log2014.log  ##显示文件后5行
    2014-09
    2014-10
    2014-11
    2014-12
    [root@localhost ~]# tail -f test.log  ##持续观察文件的最后迭代
    PING 192.168.120.204 (192.168.120.204) 56(84) bytes of data.
    64 bytes from 192.168.120.204: icmp_seq=1 ttl=64 time=0.038 ms
    64 bytes from 192.168.120.204: icmp_seq=2 ttl=64 time=0.036 ms
    64 bytes from 192.168.120.204: icmp_seq=3 ttl=64 time=0.033 ms
    64 bytes from 192.168.120.204: icmp_seq=4 ttl=64 time=0.027 ms
    64 bytes from 192.168.120.204: icmp_seq=5 ttl=64 time=0.032 ms
    

  • 相关阅读:
    知识付费时代:屌丝程序员如何用技术实现
    过完年了,要不要辞职?
    程序猿不得不知道的业内“黑话”
    Go 2 Draft Designs
    11 Go 1.11 Release Notes
    10 Go 1.10 Release Notes
    09 Go 1.9 Release Notes
    win10系统电脑无法识别u盘的解决办法
    IDEA导入Git项目后右键项目找不到Git选项的解决方法
    Redis在windows下安装与配置
  • 原文地址:https://www.cnblogs.com/paulwinflo/p/5408478.html
Copyright © 2011-2022 走看看