每天一个linux命令(14):head 命令
2016-02-14 11:36
633 查看
head 与 tail 就像它的名字一样的浅显易懂,它是用来显示开头或结尾某个数量的文字区块,head 用来显示档案的开头至标准输出中,而 tail 想当然尔就是看档案的结尾。
1.命令格式:
head [参数]... [文件]...
2.命令功能:
head 用来显示档案的开头至标准输出中,默认head命令打印其相应文件的开头10行。
3.命令参数:
-q 隐藏文件名
-v 显示文件名
-c<字节> 显示字节数
-n<行数> 显示的行数
4.使用实例:
实例1:显示文件的前n行
命令:
head -n 5 log2014.log
输出:
[root@localhost test]# cat log2014.log
2014-01
2014-02
2014-03
2014-04
2014-05
2014-06
2014-07
2014-08
2014-09
2014-10
2014-11
2014-12
==============================
[root@localhost test]# head -n 5 log2014.log
2014-01
2014-02
2014-03
2014-04
2014-05[root@localhost test]#
实例2:显示文件前n个字节
命令:
head -c 20 log2014.log
输出:
[root@localhost test]# head -c 20 log2014.log
2014-01
2014-02
2014
[root@localhost test]#
实例3:文件的除了最后n个字节以外的内容
命令:
head -c -32 log2014.log
输出:
实例4:输出文件除了最后n行的全部内容
命令:
head -n -6 log2014.log
输出:
1.命令格式:
head [参数]... [文件]...
2.命令功能:
head 用来显示档案的开头至标准输出中,默认head命令打印其相应文件的开头10行。
3.命令参数:
-q 隐藏文件名
-v 显示文件名
-c<字节> 显示字节数
-n<行数> 显示的行数
4.使用实例:
实例1:显示文件的前n行
命令:
head -n 5 log2014.log
输出:
[root@localhost test]# cat log2014.log
2014-01
2014-02
2014-03
2014-04
2014-05
2014-06
2014-07
2014-08
2014-09
2014-10
2014-11
2014-12
==============================
[root@localhost test]# head -n 5 log2014.log
2014-01
2014-02
2014-03
2014-04
2014-05[root@localhost test]#
实例2:显示文件前n个字节
命令:
head -c 20 log2014.log
输出:
[root@localhost test]# head -c 20 log2014.log
2014-01
2014-02
2014
[root@localhost test]#
实例3:文件的除了最后n个字节以外的内容
命令:
head -c -32 log2014.log
输出:
实例4:输出文件除了最后n行的全部内容
命令:
head -n -6 log2014.log
输出:
相关文章推荐
- 每天一个linux命令(13):less 命令
- linux tar 压缩解压命令
- Linux下activeMQ的安装和启动
- (转)Linux下清理Cache方法
- Linux源码打包工具CheckInstall
- Linux ALSA声卡驱动之四:Control设备的创建
- 阿里云服务器CentOS 6.3下快速安装部署 LAMP 、vsftpd 环境的方法
- linux系统常用监控工具
- linux网桥配置brctl
- Linux一些命令
- Linux od命令(以指定进制显示文件)
- centos6.5 设置固定ip
- Centos 升级python2.7到python3.4.2
- 如何用十条命令在一分钟内检查Linux服务器性能
- linux运维实战练习-2016年1月19日-2月3日课程作业(练习)
- 完美解决 Linux 下 Sublime Text 中文输入
- Linux系统编程基础知识 2015/1/14
- Linux进程管理
- 【备忘】Linux Samba 简易设置
- PHP执行linux命令的6个函数