Micro 17, wc -l

This is the seventeenth post in the series Microposts. Start reading at the beginning, Micro 1.

1

A panoramic view of Santa Clarita Valley from one of the mountains in Placerita Canyon. The hills are neither jagged nor rolling, but something in between, and the LA suburb looks surprisingly peaceful and green for how developed it is.

2

A car's dashboard readout, showing engine temperature, outside temperature, range, and notably, a large letter D.

I guess my dad got one of those cars that gives you a grade based on how efficiently you’re driving.

But I keep getting a D grade and I didn’t need this kind of judgement from a car.

3

The dashboard, but the D now reads P.

It’s okay I changed to a Pass/No Pass right when I got to where I was going.

4

I just recently learned that wc -lThe command-line program that counts characters, words, and lines. wc -l counts lines. technically counts newlines.

So if your document doesn’t end in a newline, it might not be counting the last line.

5

echo -n prints the content without appending a newline.

$ echo -n "1
> 2
> 3" | wc -l
       2

6

This behavior is intentional! POSIXPOSIX.1-2017 3.206 is very clear what a line means!

3.206 Line

A sequence of zero or more non-<newline> characters plus a terminating <newline> character.

And wc:

-l
Write to the standard output the number of <newline> characters in each input file.

7

This makes sense!

It is also Awful! Every script I’ve ever written with wc -l is possibly wrong.

8

He spoke lazily, and without care to his languidge

9

Yeah you know I’m on Twitch. I’m a full time steamer. Mostly vegetables, but sometimes eggs and buns too. Heck, got a wrinkly shirt?

Videogames? That sounds a like a bad idea. Water and electronics don’t mix.