Unix Tip #4 (Tail)

Learn to wag your unix tail.  Get those log file viewing habits under control.


This entry was posted in Community, Productivity and tagged , , , . Bookmark the permalink.

4 Responses to Unix Tip #4 (Tail)

  1. That log rotation is pretty neat! Thanks for the tip!

  2. JGeiger says:

    tail -100 filename will show the last 100 lines of filename.

    You don’t need the -n.

  3. does no specification default to numbers or bytes? for some reason i was thinking no specification defaulted to bytes.

  4. Felix says:

    Couple of remarks here:
    - tail defaults to showing the last 10 lines
    - tail -n 5, tail -n -5 and tail -5 all do the same: they show the last five lines of the file
    - tail -n +5 and tail +5 all do the same: they show all the lines from the fifth (included) till the end of the file
    - tail always shows the end of the file starting from a certain definable line/block/byte

    I think you got some stuff a little mixed up, especially regarding positive line numbers (you have to explicitely say +5 to start at the fifth line, as opposed to 5 or -5 starting at the fifth line before end), the fact that tails always ouputs the end of the file. To get the first lines of a file, go with the well-named head :-)