$head
Output the first part (top lines) of text files.
head [OPTIONS] [FILE...]Try `head` Live in Interactive Sandbox
Zero-install client simulation with real-time feedback.
Overview & How head Works
`head` outputs the beginning portion of files, displaying the first 10 lines by default. It is ideal for quickly inspecting file headers, CSV schemas, or top log entries without loading massive files into memory.
Common Flags & Command Options
| Flag / Option | Description |
|---|---|
| -n [NUM] | Print the first NUM lines instead of the default 10. |
| -c [NUM] | Print the first NUM bytes of each file. |
| -q | Quiet mode; never print headers giving file names. |
Practical Real-World Examples
head -n 5 /var/log/syslogExtracts and prints only the first 5 lines of the system log file.
Frequently Asked Questions
How do you view everything except the last 10 lines?
Use `head -n -10 [file]` to output all lines from the start up to the last 10 lines.
Related Linux Commands
Search for matching string patterns or regular expressions inside text files.
Concatenate and print file contents directly to the terminal standard output.
Output the last part (bottom lines) of files or stream real-time logs.
Print newline, word, and byte counts for files.
Print text strings or write data to files using shell redirection.
Stream editor for filtering and transforming text using pattern substitutions.