head

head命令用于显示文件的开头的内容。在默认情况下,head命令显示文件的头10行内容。

格式

head [参数] [文件]

参数选项

参数 备注
-q 不显示文件名的头信息
-v 总是显示文件名的头信息
-c <字节> 显示字节数
-n <行数> 显示的行数

实例

  • 显示文件的前n行

    命令: **head -n 5 myFile **

[root@VM_0_9_centos ~]# cat myFile
this is line 1;
this is line 2;
this is line 3;
tihs is line 4;
this is line 5;
this is line 6;
this is line 7;
this is line 8;
this is line 9;
this is line 10;
this is line 11;
this is line 12;
this is line 13;
this is line 14;
[root@VM_0_9_centos ~]# head -n 5 myFile
this is line 1;
this is line 2;
this is line 3;
tihs is line 4;
this is line 5;
  • 显示文件前n个字节

    命令: **head -c 10 myFile **

[root@VM_0_9_centos ~]# head -c 10 myFile
this is li
[root@VM_0_9_centos ~]#
  • 文件的除了最后n个字节以外的内容

命令: **head -c -10 myFile **

root@VM_0_9_centos ~]# head -c 10 myFile
this is li[root@VM_0_9_centos ~]# head -c -10 myFile
this is line 1;
this is line 2;
this is line 3;
tihs is line 4;
this is line 5;
this is line 6;
this is line 7;
this is line 8;
this is line 9;
this is line 10;
this is line 11;
this is line 12;
this is line 13;
this is
[root@VM_0_9_centos ~]#
  • 输出文件除了最后n行的全部内容

    命令: **head -n -6 myFile **

[root@VM_0_9_centos ~]# head -n -10 myFile
this is line 1;
this is line 2;
this is line 3;
tihs is line 4;
[root@VM_0_9_centos ~]#

参考

最新文章

  1. 驱动01.LED
  2. Kooboo CMS - Html.FrontHtml[Helper.cs] 各个方法详解
  3. SQL Server多表多列更新
  4. EF Core 1.0中使用Include的小技巧
  5. POJ 3170 Knights of Ni (暴力,双向BFS)
  6. Synchronized vs SyncRoot
  7. ASP.NET Core中间件实现分布式 Session
  8. 4-sum问题
  9. Vue.js04:vue样式-通过属性绑定方式为元素设置class类样式
  10. elasticsearch 介绍
  11. C#窗口编程时TextBox中的换行
  12. JVM系列三:JVM参数设置
  13. 浅谈范德蒙德(Vandermonde)方阵的逆矩阵的求法以及快速傅里叶变换(FFT)中IDFT的原理
  14. (5)可变、不可变和hash函数
  15. 【转载】如何在 Github 上发现优秀的开源项目?
  16. LinkServer--在Job中使用Linkserver注意事项
  17. Organising the Organisation(uva10766)(生成树计数)
  18. BZOJ2800 [Poi2012]Leveling Ground 【扩展欧几里得 + 三分 + 堆】
  19. weUI框架在github下载地址
  20. 【C++】C++的构造函数

热门文章

  1. 2018-2019-2 20175307 实验四《Android程序设计》实验报告
  2. 洛谷P2661 信息传递(最小环,并查集)
  3. 为什么每次打出的包都是Release版本呢?
  4. day14—jQuery UI 之dialog部件
  5. hadoop分布式环境安装
  6. SqL语句基础之增删改查
  7. Docker 官网文档翻译汇总
  8. Python笔记(十四)_永久存储pickle
  9. mooc-IDEA 编写高质量代码--009
  10. JUnit的基本使用