cat 查看文件内容
[root@mysql tmp]# cat 2.txt
1234
-n 查看行号
[root@mysql tmp]# cat -n 2.txt
?????1 1234
?????2 1
?????3 2
?????4 3
?????5 4
?????6 5
tac 倒过来显示文件内容
[root@mysql tmp]# tac 2.txt
5
4
3
2
1
1234
less 分页显示文件内容
history | less
87 ls
???88 cd /class
???89 ls
???90 cd 01
???91 ls
???92 vim n
???93 vim number.py
???94 python
???95 ls
???96 vim number.py
???97 vim age.py
???98 python age.py
???99 vim age.py
??100 python age.py
??101 vim age.py
??102 python age.py
??103 vim age.py
??104 python age.py
head 取文件前几行
-n* 取文件前*行 默认取10行
[root@mysql tmp]# head -n3 2.txt
1234
1
2
tail 取文件后几行
-n* 取文件后*行
[root@mysql tmp]# tail -n2 2.txt
4
5
Cut
取列
-d 指定分隔符
-f 取列
-f3,5 取第三列和第五列
-f3-5 取第三列到第五列
[root@mysql tmp]# cat 3.txt
i am love,oldboy and oldgril id
[root@mysql tmp]# cut -d "
" -f2,4 3.txt
am and
查看文件及内容处理命令 cat tac less head tail cut
原文:http://www.cnblogs.com/jksbaduen/p/7834518.html