linux下查看文件内容cat,more,less

来源:互联网 时间:2026-02-26 18:06:53 作者:

系统大全为您提供
1. 查看文件内容常用的命令 cat : 由第一行显示文件内容 tac: 从最后一行开始显示,与cat相反 nl : 文件内容和行号一起输出 more: 一页一页显示 less: 与more类似,可以往前翻页 head: 取头部几行 tail: 取尾部几行 od: 以二进制方式读取文件内容 2. cat命令 查看cat的参数 cat --h $ cat --h Usage: cat [OPTION] [FILE]... Concatenate FILE(s), or standard input, to standard output.     -A, --show-all           equivalent to -vET                            与-vET等价   -b, --number-nonblank    number nonblank output lines                            输出行号,只针对非空白行   -e                       equivalent to -vE                            与-vE等价   -E, --show-ends          display $ at end of each line                            文件末尾展示$     -n, --number             number all output lines                            输出行号   -s, --squeeze-blank      never more than one single blank line                            合并多个空白行,只输出一行   -t                       equivalent to -vT   -T, --show-tabs          display TAB characters as ^I                            将 TAB 展示为^I   -v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB                            展示一些看不出来的字符 $ cat 1 hello   world   hello   linux 查看行号和特殊符号 $ cat -n 1      1  hello   world      2      3      4  hello   linux      5   $ cat -A 1  hello^Iworld^M$ ^M$ ^M$ hello^Ilinux^M$ ^M$ -A参数 结尾以 $结束, TAB 以^I展示, ^M表示windiows下的回车键。 cat一次全展示文件,当文件比较大时,来不及看就翻屏过了。推荐使用more或less来查看文件。 3. more命令 more可翻页查看。 $ more filename 常用命令:空格 space : 向下翻页 Enter : 向下滚动一行 /字符串 : 向下查询字符串 :f : 显示当前行号 q : 退出 b : 往回翻页,只在文件有作用,对管道无作用。 4. less命令 less也是一页一页的查看,与more不同的是可以向上翻页 $ less filename 常用命令:空格 space : 向下翻一页 Enter : 向下一行 [PageDown] : 向下一页: [PageUp] : 向上一页 /字符串: 向下查询 ?字符串: 向上查询 n : 重复前一个查询 / 或 ? N : 反向前一个查询 / 或 ? q : 退出less的参数与man命令的参数类似,因为man命令就是调用less显示说明文档的。 
 
  
  以上就是系统大全给大家介绍的如何使的方法都有一定的了解了吧,好了,如果大家还想了解更多的资讯,那就赶紧点击系统大全官网吧。 
 
本文来自系统大全https://www.herecours.com/d/file/efpub/2026/26-26/20260226175411569728

相关推荐