head

From NetBSD Wiki

Jump to: navigation, search

The head(1) command shows the first 10 lines of a file (or pipe, or anything else that is a File descriptor).

Example:

$ head wocky.txt
`Twas brillig, and the slithy toves
  Did gyre and gimble in the wabe:
  All mimsy were the borogoves,
  And the mome raths outgrabe.

"Beware the Jabberwock, my son!
  The jaws that bite, the claws that catch!
  Beware the Jubjub bird, and shun
  The frumious Bandersnatch!"

$

You can also adjust the number of lines head(1) shows:

$ head -n 2 wocky
`Twas brillig, and the slithy toves
  Did gyre and gimble in the wabe:
$

For backwards-compatibility, the NetBSD implementation of head(1) also supports any option that is a number instead of the -n:

$ head -2 wocky

If more than one file is given on the commandline, it will print the file's name between ==> and <== arrows. To shut that up, use the -q option. If no filenames are given, it expects its input on stdin.

See also

View source code (Please report any bugs or suggestions here).

Retrieved from "http://wiki.netbsd.se/head"
Personal tools