The head command reads the first few lines of any text given to it as 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] ...

Flags

  • -n: can be used followed by number, which indicates the number of lines desired in the output. This flag can be used without n: the hyphen and the number (with no intervening space) are enough to tell head how many lines to return.
    head -n15 file1.txt 
    head -n 15 file1.txt
    head -15 file1.txt
  • -c: similar to -n with the only difference being that the number stands for bytes instead of the number of lines and the fact that it can't be used without explicitly typing the -c.