每天一个linux命令:head(15)
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 ~]#
参考
每天一个linux命令:head(15)的更多相关文章
- 每天一个linux命令(15)-tail
tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不断刷新, ...
- 每天一个 Linux 命令(15):tail 命令
tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不但刷新, ...
- 每天一个linux命令(15):tail 命令
tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不但刷新, ...
- 每天一个linux命令(15):whereis 命令
whereis命令只能用于程序名的搜索,而且只搜索二进制文件(参数-b).man说明文件(参数-m)和源代码文件(参数-s).如果省略参数,则返回所有信息. 和 find相比,whereis查找的速度 ...
- 每天一个Linux命令(15)--tail命令
tail 命令从指定点开始将文件写到标准输出.使用 tail 命令的 -f 选项可以方便的查阅正在改变的日志文件 , tail -f filename 会把 filename 里最尾 ...
- (转)每天一个linux命令(15):tail 命令
场景:每次查看服务端的日志时候都需要反复重新加载服务端的日志.用tail命令可以很方便的查看服务器上的日志更新! tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅 ...
- 【转】每天一个linux命令(15):tail 命令
原文网址:http://www.cnblogs.com/peida/archive/2012/11/07/2758084.html tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f ...
- 每天一个linux命令(15):head命令
版权声明更新:2017-05-19博主:LuckyAlan联系:liuwenvip163@163.com声明:吃水不忘挖井人,转载请注明出处! 1 文章介绍 本文介绍了Linux下面的mv命令. 2. ...
- 每天一个Linux命令(15)tail命令
tail命令用于输入文件中的尾部内容.tail命令默认在屏幕上显示指定文件的末尾10行. 如果给定的文件不止一个,则在显示的每个文件前面加一个文件名标题. (1)用法: 用法: tail ...
- 每天一个 Linux 命令(21):find命令之xargs
在使用 find命令的-exec选项处理匹配到的文件时, find命令将所有匹配到的文件一起传递给exec执行.但有些系统对能够传递给exec的命令长度有限制,这样在find命令运行几分钟之后,就会出 ...
随机推荐
- Oracle Data Guard Protection Modes
Maximum Availability This protection mode provides the highest level of data protection that is poss ...
- EZOJ #374学习
分析 二分天数 暴力判断即可 代码 #include<bits/stdc++.h> using namespace std; #define int long long ],b[],c[] ...
- linux-批量修改目录下后缀shell
#!/bin/bashcd /optrename .sh .shell *.shecho "后缀修改成功"
- curl的一些常用命令
在学习nodejs中get到了一项新的技能crul curl 可以给在命令行上面给node服务器发送一些信息,然后得到服务器返回而响应信息,在命令行中打印出来. 下面是我整理的一些常用的命令:
- 设计模式 - 装饰器模式(Decorator)
简介 场景 通过继承和关联都可以给对象增加行为,区别如下: 继承是静态的(无法在程序运行时动态扩展),且作用于所有子类.硬编码,高耦合. 通过装饰器可以在运行时添加行为和属性到指定对象.关联关系就是在 ...
- go tour - Go 入门实验教程
在线实验地址 - 官网 在线实验地址 - 国内 可以将官方教程作为独立程序在本地安装使用,这样无需访问互联网就能运行,且速度更快,因为是在你的机器上构建并运行代码示例. 本地运行此教程的中文版的步骤如 ...
- redis 集群新增节点,slots槽分配,删除节点, [ERR] Calling MIGRATE ERR Syntax error, try CLIENT (LIST | KILL | GET...
redis reshard 重新分槽(slots) https://github.com/antirez/redis/issues/5029 redis 官方已确认该bug redis 集群重新(re ...
- 【PP系列】SAP 取消报工后修改日期
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[PP系列]SAP 取消报工后修改日期 前言 ...
- mooc-IDEA 应用快捷键自动创建测试类--010
十六.IntelliJ IDEA -应用快捷键自动创建测试类 Step1:在类或接口上,按ctrl+shift+t 选择Create New Test... 则在相应测试包下.创建该测试类. 测试类:
- Asp.Net Core 发布和部署 Linux + Nginx
安装.NET Core SDK 官方介绍:https://dotnet.microsoft.com/download/linux-package-manager/centos/sdk-current ...