What happens if you use `head -n`?

QuestionsQuestions8 SkillsProDec, 17 2025
093

That's a great follow-up question! You're thinking ahead!

If you use head -n (without a number), it's the same as just using head alone, which by default displays the first 10 lines of the file.

However, typically, you would use head -n followed by a number to specify exactly how many lines you want to see.

For example:

  • head -n5 /tmp/hello would display the first 5 lines of the /tmp/hello file.
  • head -n1 /tmp/hello would display only the first line of the /tmp/hello file.

You actually executed head -n1 /tmp/hello earlier in your history, and it correctly showed just the first line:

Hi,

So, in summary:

  • head -c NUMBER displays the first NUMBER of bytes.
  • head -n NUMBER (or just head -NUMBER) displays the first NUMBER of lines.

Do you want to try an example with head -n now?

0 Comments

no data
Be the first to share your comment!