head [option]... [file]...
[功能]
列印檔案的開頭部分。
[描述]
預設head命令列印其相應檔案的開頭10行。
[舉例]
*檢視的測試檔案內容:
[root@lv-k samba]# cat 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 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
*列印檔案的開始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
*列印檔案的頭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.
*列印除了最後20行的內容:
[root@lv-k samba]# head -n -20 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]
這裡,我們可以看出來,使用"-"字首的數字表示指明不會顯示相應大小的內容。
[其它]
更多的資訊,可以參考"info head".
linux命令 head 命令
head 與 tail 就像它的名字一樣的淺顯易懂,它是用來顯示開頭或結尾某個數量的文字區塊,head 用來顯示檔案的開頭至標準輸出中,而 tail 想當然爾就是看檔案的結尾。1 命令格式 head 引數 檔案 2 命令功能 head 用來顯示檔案的開頭至標準輸出中,預設head命令列印其相應檔案的...
Linux命令學習 14 head 命令
head 與 tail 就像它的名字一樣的淺顯易懂,它是用來顯示開頭或結尾某個數量的文字區塊,head 用來顯示檔案的開頭至標準輸出中,而 tail 想當然爾就是看檔案的結尾。1 命令格式 head 引數 檔案 2 命令功能 head 用來顯示檔案的開頭至標準輸出中,預設head命令列印其相應檔案的...
linux命令學習head和tail
linux命令head和tail是一對 more和less是一對。head和tail 乙個頭,乙個尾。標誌 b number 從 number 變數表示的 512 位元組塊位置開始讀取指定檔案。c number 從 number 變數表示的位元組位置開始讀取指定檔案。f 如果輸入檔案是常規檔案或如果...