O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

head — stdin  stdout  - file  -- opt  --help  --version

Synopsis

head [options] [files]

The head command prints the first 10 lines of a file: great for previewing the contents.

$ head myfile
$ head * | less            Preview all files in the current directory

It’s also good for previewing the first few lines of output from a pipeline:

$ grep 'E' very-big-file | head

Useful options

-N

Print the first N lines instead of 10.

-n N

Print the first N lines instead of 10.

-c N

Print the first N bytes of the file.

-q

Quiet mode: when processing more than one file, don’t print a banner above each file. Normally, head prints a banner containing the filename.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required