News for hackers. Stuff that matters.
Re:Useless Use of Cat Award by scjody on Wednesday September 11, 2013 @03:15PM (#6369304)
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!
Re:Useless Use of Cat Award by gizmo686 on Wednesday September 11, 2013 @10:57PM (#6371782)
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.