how to use head command with its examples

  • About head : To output the first part of the file
  • Comes From : coreutils-8.4
  • Configuration Files:

Examples :

1. To output first 10 lines from the file

$ head file.txt

2. To output first specified number of bytes from file

$ head -c 10 file.txt

3. To output first specified number of lines from file

$ head -n 15 file.txt

4. To never output headers giving file names

$ head -q file.txt
$ head –quiet file.txt
$ head –silent file.txt

5. To always print the headers giving file names

$ head -v file.txt
$ head –verbose file.txt

6. To display the help for head

$ head –help

7. To print the version info for head

$ head –version

Leave a Reply

Your email address will not be published. Required fields are marked *