Line At A Time
Level 12: Just the Top (and the Bottom)
Just the Top (and the Bottom) Peek at the first and last lines of a file.

head shows a file's first lines instead of the whole thing, which is exactly what you want when a file is thousands of lines long. The -3 asks for three lines; with no flag at all you get the first ten.

tail is head's twin: it shows the LAST lines of a file. Together they are how you check the beginning and end of something enormous without printing the middle.

Real terminals lean on tail constantly, because the newest lines of a log file are at the bottom.

head -3 shopping.txtThe first three lines.
tail -2 shopping.txtThe last two lines.
Your task
  • Show the first few lines of shopping.txt
  • Show the last few lines of it

Open this level in your browser to type the commands at a live terminal that answers back.