head's Examples

to print first 5 number of linnes

head -n 2 numbers.txt

print 4 lines in numbers.txt

head -4 numbers.txt

print all lines but  nor the last 2 lines in the file

head -n -2 numbers.txt

-c option prints the N number of bytes from the initial part of the file

head -c 5 numbers.txt

-c option prints the N number of bytes from the initial part of the file

head -c 5 numbers.txt

pass the output of other commands to the input of the head

ls | head

to print header information always

head -v numbers.txt

displays multiple files

head colors.txt numbers.txt

redirect the head command to a text file

head numbers.txt > output1_file

to list all the files /etc directory using ls command and prints 10 entries 

ls /etc |head

DevOpsSchool
Typically replies within an hour

DevOpsSchool
Hi there 👋

How can I help you?
×
Chat with Us