Low Orbit Flux Logo 2 F

Linux Command - head

The head command will print the first 10 lines of a file. It can take multiple files or read from standard input.

Print first 10 lines of file:

head test1.txt

First three lines:

head -n 3  test1.txt

Print all except last 3 lines:

head -n -3  test1.txt

First 5 chars of file:

head -c 5 test1.txt

Include a header:

head -v test1.txt

Pipe output from another command:

ps -ef | head 

More than one file:

head test1.txt test2.txt

More than one file but suppress headers:

head -q test1.txt test2.txt