head [OPTION]... [FILE]...
[功能]
打印文件的开头部分。
[描述]
默认head命令打印其相应文件的开头10行。
[举例]
*查看的测试文件内容:
[root@lv-k samba]# cat -n smb.conf
1 [global]
2 workgroup = MY_GROUP
3 server string = "MySamba"
4 netbios name = "MySamba Server ip"
5 hosts allow = 127. 192.168.12. 192.168.13. 10.1.2.
6 security = share
7
8 [public1]
9 path = /home/mysamba
10 public = yes
11 writable = yes
12
13 [public2]
14 path = /root/mysamba
15 public = yes
16 writable = yes
17 browseable = yes
18 hosts allow = 10.1.2.213 10.1.2.217
19
20 [public3]
21 path = /tmp/mysamba
22 public = yes
23 writable = yes
24 browseable = yes
25 security = user
26 valid users = quietheart lv-k
27 create mask = 0700
28 directory mask = 0700
*打印文件的开始10行:
[root@lv-k samba]# head smb.conf
[global]
workgroup = MY_GROUP
server string = "MySamba"
netbios name = "MySamba Server ip"
hosts allow = 127. 192.168.12. 192.168.13. 10.1.2.
security = share
[public1]
path = /home/mysamba
public = yes
*打印文件的头5行:
[root@lv-k samba]# head -n 5 smb.conf
[global]
workgroup = MY_GROUP
server string = "MySamba"
netbios name = "MySamba Server ip"
hosts allow = 127. 192.168.12. 192.168.13. 10.1.2.
*打印文件的开始12个字节:
[root@lv-k samba]# head -c 12 smb.conf
[global]
wor
*打印文件的除了最后12个字节以外的内容:
[root@lv-k samba]# head -c -12 smb.conf
[global]
workgroup = MY_GROUP
server string = "MySamba"
netbios name = "MySamba Server ip"
hosts allow = 127. 192.168.12. 192.168.13. 10.1.2.
security = share
[public1]
path = /home/mysamba
public = yes
writable = yes
[public2]
path = /root/mysamba
public = yes
writable = yes
browseable = yes
hosts allow = 10.1.2.213 10.1.2.217
[public3]
path = /tmp/mysamba
public = yes
writable = yes
browseable = yes
security = user
valid users = quietheart lv-k
create mask = 0700
directory
这里,我们可以看出来,使用"-"前缀的数字表示指明不会显示相应大小的内容。