linux命令中的head命令

上一篇 / 下一篇  2017-08-09 16:51:12 / 个人分类:linux

转载自:http://blog.csdn.net/u010585120/article/details/48027611 收藏以便学习
head命令和tail命令就像他的名字一样浅显易懂,它是用来显示开头或者结尾某个数量的文字区块,head用来显示档案的开头至标准输出当中,而tail想当然就是查看档案的结尾。

命令格式

head  [参数]   【文件】

命令功能

head用来显示档案的开头至标准输出当中,默认head命令打印其相应文件的开头10行。

命令参数

-q    隐藏文件名

-v    显示文件名

-c   显示字节数

-n 显示的行数

使用实例

显示文件的前100个字节

[html] view plain copy
  1. [root@centos65 CP000154]# head -c 100 _source   
  2. {"references":[{"referencetag":"1  (bases 1 to 5394884)","journal":"J. Bacteriol. 192 (22), 6103-610[root@centos65 CP000154]#   


head -c -100  filename 显示除了最后n个字节以外的其他内容


head -n 5   filename   显示文档中的前5行

head -n -5 filename   显示文件除了最后n行以外的其他内容


TAG:

 

评分:0

我来说两句

Open Toolbar