4 ms·
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 w
by scjody 13y ago
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!
- gizmo686 13y agoThis 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.