美文网首页
软件测试基础知识-Linux篇(3)

软件测试基础知识-Linux篇(3)

作者: 燕窝Emily | 来源:发表于2021-04-01 15:49 被阅读0次

    1.直接检视文件内容

    1.cat

    [root@study ~]# cat [-AbEnTv]
    选项与参数:
    -b : 列出行号, 仅针对非空白行做行号显示, 空白行不标行号!
    -E : 将结尾的断行字符 $ 显示出来;
    -n : 打印出行号, 连同空白行也会有行号, 与 -b 的选项不同;
    -v : 列出一些看不出来的特殊字符

    bogon:学习 yuyan$ cat hello.txt
    hello from hogwarts
    
    hello from sevenribyi
    
    hello from testerhome
    bogon:学习 yuyan$ cat -b hello.txt
         1  hello from hogwarts
    
         2  hello from sevenribyi
    
         3  hello from testerhome
    bogon:学习 yuyan$ cat -e hello.txt
    hello from hogwarts$
    $
    hello from sevenribyi$
    $
    hello from testerhome$
    bogon:学习 yuyan$ cat -n hello.txt
         1  hello from hogwarts
         2
         3  hello from sevenribyi
         4
         5  hello from testerhome
    bogon:学习 yuyan$ cat -v hello.txt
    hello from hogwarts
    
    hello from sevenribyi
    
    hello from testerhome
    

    2.nl (添加行号打印)

    [root@study ~]# nl [-bnw] 文件

    选项与参数:

    b 指定行号指定的方式, 主要有两种****:

    -b a : 表示不论是否为空行, 也同样列出行号( 类似 cat -n) ;

    -b t : 如果有空行, 空的那一行不要列出行号( 默认值) ;

    n 列出行号表示的方法, 主要有三种****:

    -n ln : 行号在屏幕的最左方显示;

    -n rn : 行号在自己字段的最右方显示, 且不加 0 ;

    -n rz : 行号在自己字段的最右方显示, 且加 0 ;

    -w : 行号字段的占用的字符数。

    bogon:学习 yuyan$ nl -b a  hello.txt
         1  hello from hogwarts
         2
         3  hello from sevenribyi
         4
         5  hello from testerhome
    bogon:学习 yuyan$ nl -b t  hello.txt
         1  hello from hogwarts
    
         2  hello from sevenribyi
    
         3  hello from testerhome
    bogon:学习 yuyan$ nl -b a -n rz  hello.txt
    000001  hello from hogwarts
    000002
    000003  hello from sevenribyi
    000004
    000005  hello from testerhome
    bogon:学习 yuyan$ nl -b a -n rz -w 3  hello.txt
    001 hello from hogwarts
    002
    003 hello from sevenribyi
    004
    005 hello from testerhome
    

    2.可翻页检视

    1.more(一页一页翻动)

    空白键 ( space) : 代表向下翻一页;

    Enter : 代表向下翻“一行”;

    /字串 : 代表在这个显示的内容当中, 向下搜寻“字串”这个关键字;

    :f : 立刻显示出文件名以及目前显示的行数;

    q : 代表立刻离开 more , 不再显示该文件内容。

    b 或 [ctrl]-b : 代表往回翻页, 不过这动作只对文件有用, 对管线无用。

    2.Less (一页一页翻动)

    空白键 : 向下翻动一页;

    [pagedown]: 向下翻动一页;

    [pageup] : 向上翻动一页;

    /字串 : 向下搜寻“字串”的功能;

    ?字串 : 向上搜寻“字串”的功能;

    n : 重复前一个搜寻 ( 与 / 或 ? 有关! )

    N : 反向的重复前一个搜寻 ( 与 / 或 ? 有关! )

    g : 前进到这个数据的第一行去;

    G : 前进到这个数据的最后一行去 ( 注意大小写) ;

    q : 离开 less 这个程序;

    3.数据撷取

    1.head ( 取出前面几行)

    [root@study ~]# head [-n number] 文件

    选项与参数:

    -n : 后面接数字, 代表显示几行的意思

    2.tail ( 取出后面几行)

    [root@study ~]# tail [-n number] 文件

    选项与参数:

    -n : 后面接数字, 代表显示几行的意思

    -f : 表示持续侦测后面所接的文件名, 要等到按下[ctrl]-c才会结束tail的侦测

    bogon:学习 yuyan$ head -n 1 hello.txt
    hello from hogwarts
    bogon:学习 yuyan$ tail -n 1 hello.txt
    hello from testerhome
    

    😁愿每天都进步一点点😁

    相关文章

      网友评论

          本文标题:软件测试基础知识-Linux篇(3)

          本文链接:https://www.haomeiwen.com/subject/auvtkltx.html