If you're doing a one-off pipeline on the command line, you can even start with less!
"I want to look through this file..."
less file
"Oh, that's long, I want to look at all the foos..." less file | grep foo
"How many foos are there?" less file | grep foo | wc -l
Try it, it works!This is not some magic behavior of pipelines. Rather, less (like many other terminal programs) is explicitly programmed to behave differently if the output is a terminal. Specifically, the less source code has this comment in it:
"/*
* Output is not a tty.
* Just copy the input file(s) to output.
*/"
grep does this to, which is why the color-coding control characters don't mess up other commands.
FWIW, that's the exact same way I approach that sort of manipulation. Start with the most basic operation, then construct a pipeline going left to right, adding filters / operations as needed to get to the result.
"Ok, I want to read this file..."
"Then I want to find foo" "Oh, and I want to know how many lines of foo there are" In this trivial example, I could have inserted "-c" with only a few keystrokes, but on a 200 character string of commands it's faster and easier to tack "wc -l" on at the end. Plus I'm not strong enough with grep to do every manipulation I might want, so sometimes that grep will be followed by some perl, or a sort, etc.