1.cat
用途:查看文件内容
用法:cat -选项 文件
选项:-b 显示行号(空白行不显示)
-n 显示行号包括空白行
[root@localhost test]# cat -b filetest
1 第1行
2 第2行
3 第3行
4 第4行
[root@localhost test]# cat -n filetest
1 第1行
2 第2行
3 第3行
4
5 第4行
2.more
用途:分页查看
用法:空格切换下一页,q退出
[root@localhost test]# more filetest
3.less
用途:分页查看
用法:空格(下一页),方向键(上下回翻),q键(退出)
[root@localhost test]# less filetest
4.head
用途:查看文件内容(从头开始,默认前十行)
用法:head 选项 文件
选项:-c nk 显示前nkb
-n 显示前n行
[root@localhost test]# head -c 1k filetest
[root@localhost test]# head -n 3 filetest
5.tail
用途:查看文件尾部内容(默认10行)
用法:tail - 选项 文件
选项:-c nk
-n (用法同head)
[root@localhost test]# tail -n 3 filetest
[root@localhost test]# tail -c 1k filetest
6.wc
用途:显示文件的行,单词与字节统计信息
用法:wc -选项 文件
选项:-c 显示文件字节数统计信息
-l 显示行数统计信息
-w 显示单词数统计信息
[root@localhost test]# wc -clw filetest
10 9 73 filetest
7.grep
用途:查找关键字并打印匹配行
用法:grep -选项 匹配模式 文件
选项:-i 忽略大小写
-v 取反匹配
-w 匹配单词
-color 显示颜色
[root@localhost test]# grep -i the filetest #不区分大小写
[root@localhost test]# grep -w the filetest
[root@localhost test]# grep -v the filetest #过滤出不包含the的
[root@localhost test]# grep -color th filetest #过滤出包含th的行
8.echo
用途:显示一行指定的字符串
用法:echo -选项 字符串
选项:-n 不输出换行,默认echo输出内容后会换行
-e 支持反斜杠开始的转义字符,屏蔽反斜杠字符后面的原本意义
[root@localhost test]# echo -n "hello the world"
hello the world[root@localhost test]#
[root@localhost test]# echo -e "\a" #蜂鸣器会响一下