News for hackers. Stuff that matters.
Re:Useless Use of Cat Award by sliverstorm on Wednesday September 11, 2013 @11:13AM (#6367675)
Pipes also match my thought flow. "wc -l" is a good example.

"Ok, I want to read this file..."

    cat file
"Then I want to find foo"

    cat file | grep foo
"Oh, and I want to know how many lines of foo there are"

    cat file | grep foo | wc -l

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.
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.

Re:Useless Use of Cat Award by mindcrime on Wednesday September 11, 2013 @12:09PM (#6368047)
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.