head
file managementLinux/Unix
The head command is one of the most frequently used commands in Linux/Unix-like operating systems. head Output the first part of files
Quick Reference
Command Name:
head
Category:
file management
Platform:
Linux/Unix
Basic Usage:
head [options] [arguments]
Common Use Cases
Syntax
head [options] [file...]
Options
Option | Description |
---|---|
-c, --bytes=[-]NUM |
Print the first NUM bytes of each file; with leading '-', print all but the last NUM bytes |
-n, --lines=[-]NUM |
Print the first NUM lines instead of the first 10; with leading '-', print all but the last NUM lines |
-q, --quiet, --silent |
Never print headers giving file names |
-v, --verbose |
Always print headers giving file names |
-z, --zero-terminated |
Line delimiter is NUL, not newline |
--help |
Display help information and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the head
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
head file.txt