ADVERTISEMENT

Linux Commands ❯ head

head

Print the first 10 lines of each FILE to standard output.
syntax:

head [OPTION]... [FILE]...
  • head my_file1
    display the first 10 lines from my_file1
  • head my_file1 my_file2
    display the first 10 lines from my_file1 and my_file2
  • head -c 100 my_file1
    display the first 100Bytes of my_file1
  • head -c -100 my_file1
    display the contents of my_file1 except the last 100Bytes
  • head -n 2 my_file1
    display the first 2 lines from my_file1
  • head -n -2 my_file1
    display the contents of my_file1 except the last 2 lines.
  • head -n 5 my_file1 > my_file2
    create a file called my_file2 with first 5 lines from my_file1
  • head -q my_file1 my_file2
    display the first 10 lines from my_file1 and my_file2 without any header information
  • head -v my_file1 my_file2
    display the first 10 lines from my_file1 and my_file2 separated by respective filenames header