What does the 'head' command do?

0179

The head command in Linux is used to display the beginning portion of a text file. By default, it shows the first 10 lines of the file. You can customize the number of lines displayed using the -n option.

Basic Usage

  • Default:

    head filename.txt

    This displays the first 10 lines of filename.txt.

  • Custom Number of Lines:

    head -n 15 filename.txt

    This displays the first 15 lines of filename.txt.

Benefits

  • Fast: It reads only the beginning of the file, making it quick even for large files.
  • Memory-efficient: It doesn't load the entire file into memory.
  • Preview: It allows you to quickly check the file's structure and content.

If you have more questions about using head or other commands, feel free to ask!

0 Comments

no data
Be the first to share your comment!