HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

head — Output the first part of files. See also: `tail`. More information: <https://keith.github.io/xcode-m

Submitted by: @import:tldr-pages··
0
Viewed 0 times
thecommandfilesfirstcliheadpartoutput
macos

Problem

How to use the head command: Output the first part of files. See also: tail. More information: <https://keith.github.io/xcode-man-pages/head.1.html>.

Solution

head — Output the first part of files. See also: tail. More information: <https://keith.github.io/xcode-man-pages/head.1.html>.

Output the first 10 lines of a file:
head {{path/to/file}}


Output the first 5 lines of multiple files:
head {{[-5|--lines 5]}} {{path/to/file1 path/to/file2 ...}}


Output the first n lines of a file:
head {{[-n|--lines]}} {{n}} {{path/to/file}}


Output the first n bytes of a file:
head {{[-c|--bytes]}} {{n}} {{path/to/file}}

Code Snippets

Output the first 10 lines of a file

head {{path/to/file}}

Output the first 5 lines of multiple files

head {{[-5|--lines 5]}} {{path/to/file1 path/to/file2 ...}}

Output the first `n` lines of a file

head {{[-n|--lines]}} {{n}} {{path/to/file}}

Output the first `n` bytes of a file

head {{[-c|--bytes]}} {{n}} {{path/to/file}}

Context

tldr-pages: osx/head

Revisions (0)

No revisions yet.