|
|
Subscribe / Log in / New account

Surprisingly relevant?

Surprisingly relevant?

Posted May 24, 2020 13:18 UTC (Sun) by madscientist (subscriber, #16861)
In reply to: Surprisingly relevant? by Wol
Parent article: The state of the AWK

???

There are no pipes in Jandar's suggested alternative.

This feels more like StackOverflow than LWN, but the issue is that grep foo somefile gives different output than cat somefile | grep foo and if you want the latter behavior while still avoiding UUoC, you should be using grep foo < somefile instead.


to post comments

Surprisingly relevant?

Posted May 24, 2020 13:50 UTC (Sun) by mpr22 (subscriber, #60784) [Link] (1 responses)

In what way does the output of grep pattern singlefile.txt differ from the output of cat singlefile.txt | grep?

Surprisingly relevant?

Posted May 24, 2020 17:12 UTC (Sun) by madscientist (subscriber, #16861) [Link]

You're right, grep behaves the same; my bad! I was thinking of some other tools like wc which have different output when given a filename versus reading from stdin.

This can be useful in scripting to avoid the complexity of stripping off the unwanted filename.

Surprisingly relevant?

Posted May 24, 2020 14:02 UTC (Sun) by Wol (subscriber, #4433) [Link]

Umm...

On first thoughts my reaction was "aren't < and > just different syntaxes for pipes?".

My second thought now is that "no they aren't actually pipes, they're shell built-ins".

So yeah you're right. They're pretty much identical in effect (and concept), but different in implementation and impact on the system. There's more than one way to do it ... :-)

Cheers,
Wol


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds