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