Skip to content

Latest commit

 

History

History
104 lines (85 loc) · 1.08 KB

head.md

File metadata and controls

104 lines (85 loc) · 1.08 KB
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.

Syntax

head [options] file-name

Examples

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

Showing first 2 lines

$ head -n 2 readme.txt
line1
line2

Showing first 5 lines

$ head -n 5 readme.txt
line1
line2
line3
line4
line5

Showing from multiple files

$ head -n 2 readme.txt readme-2.txt
==> readme.txt <==
line1
line2

==> readme-2.txt <==
line1
line2

Showing from all files that are starting with readme

$ head -n 2 readme*
==> readme-2.txt <==
line1
line2

==> readme-3.txt <==
line1
line2

==> readme.txt <==
line1
line2