title | description | created | updated |
---|---|---|---|
head Linux Command |
head Linux Command is used to display beginning of a text file/ piped data. |
2019-09-13 |
2019-09-13 |
head Linux Command is used to display beginning of a text file/ piped data.
head [options] file-name
For example consider the following file
$ cat readme.txt
line1
line2
line3
line4
line5
line6
line7
line8
line9
line10
line11
line12
line13
line14
line15
$ head readme.txt
line1
line2
line3
line4
line5
line6
line7
line8
line9
line10
Note: head by default shows first 10 lines
$ head -n 2 readme.txt
line1
line2
$ head -n 5 readme.txt
line1
line2
line3
line4
line5
$ head -n 2 readme.txt readme-2.txt
==> readme.txt <==
line1
line2
==> readme-2.txt <==
line1
line2
$ head -n 2 readme*
==> readme-2.txt <==
line1
line2
==> readme-3.txt <==
line1
line2
==> readme.txt <==
line1
line2