WeCodeAcademy

Peeking with head, tail and wc

Big files are long. head shows the first lines and tail the last. Use -n to say how many, and wc -l to count lines.

Examplebash
Open in editor »
/ $

Without -n, both show 10 lines. wc -w counts words instead of lines.

Examplebash
Open in editor »
/ $

The second command chains them: take the first 3 lines, then keep the last one of those. That is line 3.

Quick check

Which command shows the last 5 lines of `log.txt`?

Your turn: write the code

list.txt is created with five lines. Print only its last two lines.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.