---
layout: page
author: Agostino Monti
category-page: advanced
category-title: Advanced commands
tags: head tail text file
title: head and tail
previous-page: pages/cmd/advanced/grep.html
next-page: pages/cmd/advanced/nl.html
---
The head
command reads the first few lines of any text given to it as an input
and writes them to standard output.
If more than one input file is provided, head will return the first ten lines
from each file, precede each set of lines by the name of the file and separate
each set of lines by one vertical space.
head [flags] [file1] [file2] ...The
tail
command is similar to the head
command
except that it reads the final lines in files rather than the first lines.
tail [flags] [file1] [file2] ...
head -n15 file1.txt
head -n 15 file1.txt
head -15 file1.txt