utility
head
Output the first NUMBER lines for a positive count. GNU extensions differ across platforms. Reading a pipe may cause an early producer shutdown; this example reads a completed file.
Formal Syntax & Structure
bash syntaxbash
head -n NUMBER [FILE]...Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| NUMBER | integer | Positive line count |
Return Value
exit status
Output the first NUMBER lines for a positive count. GNU extensions differ across platforms. Reading a pipe may cause an early producer shutdown; this example reads a completed file.
Working Example
Example Snippetbash
set -o pipefailprintf '%s\n' alpha beta gamma | tee records.txt | wc -lhead -n 1 records.txttail -n 1 records.txt