格子铺网站建设方案,泰州市建设监理协会网站,个人小程序,药品网站建设存在的问题linux命令之head
1.head介绍
linux命令head用来查看文件的前N行内容#xff1b;默认head查看前10行
2.head用法
head [参数] 文件 head常用参数 参数说明-n从头显示N行#xff0c;默认显示10行#xff0c;可以不写-q隐藏文件名#xff0c;在查看两个及以上文件名的情况…linux命令之head
1.head介绍
linux命令head用来查看文件的前N行内容默认head查看前10行
2.head用法
head [参数] 文件
head常用参数 参数说明-n从头显示N行默认显示10行可以不写-q隐藏文件名在查看两个及以上文件名的情况下有效-v显示文件名-c从头显示N字节的内容
3.实例
3.1.显示文件的前5行
命令
head -n 5 a.txt
OR
head -5 a.txt
[rootcentos79-3 ~]# head -n 5 a.txt
1
2
3
4
5
[rootcentos79-3 ~]# head -5 a.txt
1
2
3
4
5
[rootcentos79-3 ~]# 3.2.显示文件的前5个字节的内容
命令
head -c 5 a.txt
OR
head -c5 a.txt
[rootcentos79-3 ~]# head -c 5 a.txt
1
2
3[rootcentos79-3 ~]# head -c5 a.txt
1
2
3[rootcentos79-3 ~]# 3.3.显示输出内容的文件名
命令
head -v a.txt
[rootcentos79-3 ~]# head a.txt
1
2
3
4
5
6
7
8
9
10
[rootcentos79-3 ~]# head -v a.txta.txt
1
2
3
4
5
6
7
8
9
10
[rootcentos79-3 ~]# 3.4.显示除文件后两行的剩余内容
命令
head -n -2 a.txt
[rootcentos79-3 ~]# cat a.txt
1
2
3
4
5
6
7
8
9
10
11
12
[rootcentos79-3 ~]# head -n -2 a.txt
1
2
3
4
5
6
7
8
9
10
[rootcentos79-3 ~]# 3.5.显示除文件后两个字符的剩余内容
命令
head -c -2 a.txt
[rootcentos79-3 ~]# cat a.txt
1
2
3
4
5
6
7
8
9
10
11
12
[rootcentos79-3 ~]# head -c -2 a.txt
1
2
3
4
5
6
7
8
9
10
11
1[rootcentos79-3 ~]# 3.6.显示内容时隐藏文件的名称
命令
head -n 5 -q a.txt b.txt
[rootcentos79-3 ~]# head -n 5 a.txt b.txt a.txt
1
2
3
4
5 b.txt
1
2
3
4
5
[rootcentos79-3 ~]# head -n 5 -q a.txt b.txt
1
2
3
4
5
1
2
3
4
5
[rootcentos79-3 ~]#