1、常用cat,直接查看,一次性全部输出
cat filename
cat -b filename 显示行号,除空白行 cat -n 显示行号,包括空白行
常用:cat filename | grep 字符
2、more 可翻页查看谁的,非一次性输出全部
空格,回车---下一行 q退出
3、less 可翻页查看谁的,非一次性输出全部 类似more
PageDown/Pageup 下一页,上一页 /字符串,向下查 ?字符串,上向查 n重复上一个查询 N 反向重复前一个查询
4、head -n 10 显示前10行数据 head -n -10 除最后十行,其它全部显示
5、tail -n filename 显示文件最后n行
常用于监控tomcat的catalina日志 tail -f catalina.out -f表示持续监测,结束按CTRL+C 其它参数-n 10; -n -10 同上
例:
[root@rusky ~]# cat test-wc this is a test for command wc A B C D E F [root@rusky ~]# cat -n test-wc 1 this is a test for command wc 2 A B C 3 D E F 4 [root@rusky ~]# cat -b test-wc 1 this is a test for command wc 2 A B C 3 D E F [root@rusky ~]# head -2 test-wc this is a test for command wc A B C [root@rusky ~]# tail -2 test-wc D E F