Skip to content

Saturday, March 20th, 2010

New Linux User

EXPLAIN: The GNU/Linux ‘Head’ Command.

November 28, 2005 by Jon  
Filed under Explanation

Canadian Coin
I have frequently used the tail command, but wasn’t ware that there was a complimentary head command.

The head command will display the first n number of lines from a specified text file. For example, to view the first 10 lines of my /var/messages file, I can type:

head /var/messages

10 is the default, but if I wanted to view only the first 3 lines, I could type:

head -3 /var/messages

As with all GNU/Linux commands, there are a variety of switches to customize the behaviour of the head command. Consult the head manpage for full information.

  • StumbleUpon
  • Digg
  • Facebook
  • Mixx
  • Google
  • TwitThis
  • Reddit
  • Yahoo! Buzz
  • Slashdot
  • E-mail this story to a friend!

Comments

6 Responses to “EXPLAIN: The GNU/Linux ‘Head’ Command.”
  1. Jon says:

    Yeah! Translated into Russian :)

  2. csp says:

    How to print the text file start from x line (eg 3rd line) to y line (eg 10th line)

  3. ed says:

    head -10 file.txt | tail -7

Trackbacks

Check out what others are saying about this post...
  1. [...] Much like the head command will display the top n number of lines of a specified file, the tail command will display the bottom n number of lines from a specified file. For example, to see the last 10 lines of my /var/messages file, I can type: tail /var/messages [...]

  2. [...] Оригинальный текст статьи [...]

  3. [...] Оригинальный текст статьи [...]



Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!


About Us | Advertise with us | Blog for EveryJoe | Privacy Policy | Terms of Use
Get This Theme | Sitemap


All content is Copyright © 2005-2010 b5media. All rights reserved.