天天看點

linux head

linux指令總結—head指令

(1)指令功能

head指令用于顯示檔案的開關的内容。在預設情況下,head指令顯示檔案的頭10行内容。

(2)指令文法

head(選項) (參數)

(3)選項說明

-n <數字>:指定顯示頭部内容的行數;

-c <字元數>:指定顯示頭部内容的字元數;

-v:總是顯示檔案名的頭資訊,顯示多個檔案時預設選項;

-q:不顯示檔案名的頭資訊,顯示單個檔案時預設選項;

(4)參數說明

檔案清單:指定顯示頭部内容的檔案清單。

(5)執行個體

執行個體1:顯示單個檔案的頭部内容—head檔案

1

2

3

4

5

6

7

8

9

10

11

<code>[root@moban ~]#head  /etc/inittab </code>

<code># inittab </code><code>is</code> <code>onlyused by upstart </code><code>for</code> <code>the </code><code>default</code> <code>runlevel.</code>

<code>#</code>

<code># adding otherconfiguration here will have no effect on your system.</code>

<code># systeminitialization </code><code>is</code> <code>started by /etc/init/rcs.conf</code>

<code># individual runlevelsare started by /etc/init/rc.conf</code>

<code># ctrl-alt-delete ishandled by /etc/init/control-alt-</code><code>delete</code><code>.conf</code>

執行個體2:顯示多個檔案的頭部内容—head 檔案 檔案

12

13

14

15

16

17

18

19

20

21

22

23

24

<code>[root@moban ~]# head  /etc/inittab /etc/fstab      </code>

<code>==&gt; /etc/inittab &lt;==</code>

<code># inittab </code><code>is</code> <code>only used by upstart </code><code>for</code> <code>the defaultrunlevel.</code>

<code># adding other configuration here will have no effect onyour system.</code>

<code># system initialization </code><code>is</code> <code>started by /etc/init/rcs.conf</code>

<code># individual runlevels are started by /etc/init/rc.conf</code>

<code># ctrl-alt-delete </code><code>is</code> <code>handled by/etc/init/control-alt-</code><code>delete</code><code>.conf</code>

<code> </code> 

<code>==&gt; /etc/fstab &lt;==</code>

<code># /etc/fstab</code>

<code># created by anaconda on mon may </code><code>11</code> <code>22</code><code>:</code><code>18</code><code>:</code><code>51</code> <code>2015</code>

<code># accessible filesystems, by reference, are maintainedunder </code><code>'/dev/disk'</code>

<code># see man pages fstab(</code><code>5</code><code>), findfs(</code><code>8</code><code>), mount(</code><code>8</code><code>) and/or blkid(</code><code>8</code><code>)</code><code>for</code> <code>more info</code>

<code>uuid=17ec9366-d335-4b07-</code><code>8890</code><code>-3765cabe746a /         ext4   defaults        </code><code>1</code> <code>1</code>

<code>uuid=1f8e61c7-de21-42e3-89c5-cb28f607d1db /boot     ext4    defaults        </code><code>1</code> <code>2</code>

    執行個體3:顯示檔案頭部指定行數的内容—head –n &lt;行數&gt;

<code>[root@moban ~]# head  -n </code><code>5</code> <code>/etc/inittab          </code>

執行個體4:顯示檔案頭部指定字元數的内容—head –c &lt;字元數&gt;

<code>[root@moban ~]# head  -c </code><code>88</code> <code>/etc/inittab   </code>

<code># adding otherconfigurati[root@moban ~]#</code>

<code></code>

上一篇: linux ls
下一篇: linux cp

繼續閱讀