5 ms·
Since the blog author is commenting here, you have this statement part way down your blog: > That is, grep doesn't support an analogous -0 flag. However, the
by pwg 5y ago
Since the blog author is commenting here, you have this statement part way down your blog:
> That is, grep doesn't support an analogous -0 flag.
However, the GNU grep variant does have an analogous flag:
-z, --null-data
Treat the input as a set of lines, each terminated by a zero byte (the ASCII NUL character) instead of a newline. Like the -Z or --null option, this option can be used with commands like sort -z to process arbitrary file names.
- chubot 5y agoAh cool, I didn't know that! I'll update the blog post. (What a cacophony of flags) Edit: It seems that grep -0 isn't taken for something else and they should have used it for consistency? The man page says it's meant to be used with find -print0, xargs -0, perl -0, and sort -z (another inconsistency)
- cben 5y agoSee https://github.com/fish-shell/fish-shell/issues/3164#issuecomment-354600352 https://github.com/fish-shell/fish-shell/issues/3164#issueco... for incomplete but large survey of NUL flags. Takeaways: (1) There is no consistency in flag names, even --long ones (2) impressively many tools do support it! Note that some affect only input or only output. (3) All do NUL-terminated, not NUL-separated. That's fortunate — matches \n usage, and gives distinct representations for [] vs [""].
- l0b0 5y agoIt's best to give up on any kind of consistency between command options. Any project is free to do anything it wants, and they all do. Someone is eventually going to come up with standard N+1[1] which does things consistently, but they are going to have to either recreate a bazillion tools or create some sort of huge translation framework configuration on top of existing tools to get there. And even then it'll take literally decades before people migrate away from the current tools. Basically, the sad truth is this isn't going to happen. [1] https://xkcd.com/927/ https://xkcd.com/927/
- deleted 5y ago[deleted]
- tyingq 5y agoI think that's because they needed to support both input and output. So there's both -Z and -z. No such thing as an uppercase 0 :)
- kragen 5y agoIt is taken in grep, just poorly documented; grep -5 means grep -C 5, and grep -0 means grep -C 0. It's not taken in sort, though, so I don't know why they didn't use -0 for sort.