linux查看文件内容命令

cat   由第一行开始显示文件内容
tac   从最后一行开始显示
nl    显示同时输出行号
more  一页一页的显示内容
less  与more类似,但其优点是,可以往前翻页
head  只看头几行
tail  只看未尾几行
od    以二进制的方式读取文件内容

cat [-n]
-n连行号一起输出到屏幕上 与nl相似

more [文件名]
more test.txt将test.txt一页一页的显示出来
ls -al | more将ls显示的内容一页页显示出来

less [文件名]
less的用法比more更有弹性,使用less可以用pageup、pagedown翻看 
less test.txt
/word 
在test.txt中搜寻word这个字符串 
:q 退出less

head [-n number] [文件名]
-n显示number行
head -n 20 test.txt 
显示test.txt前20行

tail [-n number] [文件名]
-n显示number行
tail -n 20 test.txt
显示test.txt后20行

扫描二维码关注公众号,回复: 1184420 查看本文章

head -n 20 test.txt | tail -n 10
取11-20行

hexdump

猜你喜欢

转载自dreava.iteye.com/blog/1958704