File this under #shell #functions I should have written years ago:
function grepc {
#Do a grep -c, but skipping files with no results
grep -c "$@" |grep -v ':0$'
}
File this under #shell #functions I should have written years ago:
function grepc {
#Do a grep -c, but skipping files with no results
grep -c "$@" |grep -v ':0$'
}
Oh, didn't know about -c. I usually just pipe to wc -l I guess.
-c, -l, -h, -H, and -q are my favorite #grep flags. :D
Huh, that almost became a [Marcel Duchamp] reference. 😅
I just use -v and -E
Heh, I just got to run grep grep on my shell history.
I use ripgrep if I want to, say, search a whole codebase.
...and bash instead of zsh
...and grep/awk/sed instead of jq
...and firefox instead of chrome
...and the fediverse instead of facebook
Face it... I'm an unpopular-opinion neckbeard level boss. XD
cc: @mirabilos
@amin Absolutely.
@thedoctor @amin @sotolf @mirabilos
LISTEN, I've used grep/awk/sed for very nearly a quarter century, and I find the syntax of jq bewildering, so 😝
@rl_dane @thedoctor @sotolf @mirabilos
Most of those aren't for handling complex data types, though, just manipulating lines.
@amin @thedoctor @sotolf @mirabilos
So far, I've managed to bodge it together just well enough to do what I needed, but I really would like to get more familiar with jq.
@amin @rl_dane @thedoctor @sotolf jq is absolutely bewildering, especially the insistence on filtering (splitting the input stream is so hard and counter-intuitive), but it’s an ok tool if you have JSON. Or YAML, which I [convert (user=pass public)] to JSON anywwy.
xmlstarlet is lovely!
@mirabilos @amin @thedoctor @sotolf
Is it possible to convert JSON to XML and then use xmlstarlet? 😄
@kabel42 @mirabilos @amin @thedoctor @sotolf
Sufficiently evil. XD
I remember when XML was the buzzword back in the late naughties.
@mirabilos @kabel42 @sotolf @thedoctor @amin
Well, if Google hates it, I'm probably on board by default. XD
@rl_dane @amin @thedoctor @sotolf yes, but you’ll have to find out a schema you want to use.
Of course, you could just convert…
{ "foo": ["bar", "baz"], "bar": true }
… to…
<JSONObject>
<element name="foo"><JSONArray>
<element><JSONString>bar</JSONString></element>
<element><JSONString>baz</JSONString></element>
</JSONArray></element>
<element name="bar"><JSONBoolean>true</JSONBoolean></element>
</JSONObject>
… or worse (Apple “plist”), but I suspect you’d rather have something semantically correct.
A lazy way to do this is with [iXML] (“invisible XML”, via @linguacelta of “AIn’t” fame); note you’ll most likely want the draft spec, not the release, because the latter misses a way to specify an XML alias and just uses the grammar name, which must be unique, for the XML element name (so the above mapping, which has object elements and array elements, would not be possible with the 1.0 spec).
That being said, if you do want such a systematic mapping, I could write you a little jq script to do that.
Do note that U+0000 (ouch! I wish it weren’t), U+0001‥U+0008, U+000B‥U+000C, U+000E‥U+001F, U+FFFE‥U+FFFF (ouch²!) are valid in JSON but not XML (and (X)HTML forbids further codepoints). xmlstarlet will likely refuse a document in which these occur (and no, even writing them as numeric entities like  is not permitted).
@rl_dane @mirabilos @thedoctor @sotolf
I do not feel up to subjecting my notifications to a revival of this thread right now. Bye y'all. :)
@rl_dane Those are so not comparable!

@kabel42 I see you also like to see the world burn.

@mirabilos @kabel42 @rl_dane @amin @thedoctor
Legacy is mostly the safe route to go anyway, tried and tested, I am the one that gets called if shit stops working, and I'd rather have something I know and makes sense, with tons of resources of administrators of the before times having struggled with them to help me figure out what is going on. Rather than modern stuff, with their ai documentation, discord "forums" and shipping their whole pc (docker) because they couldn't get their shit to work on a clean system :p
@kabel42 @mirabilos @rl_dane @amin @thedoctor
Hey I relied on that bug!
@sotolf @kabel42 @mirabilos @rl_dane @thedoctor
Oh haha so it was intentional. I was wondering.
@kabel42 @mirabilos @rl_dane @thedoctor @sotolf
Haha, you got it too! XD
@sotolf @kabel42 @mirabilos @rl_dane @thedoctor
Sometimes knowing the right xkcd is like shooting fish in a barrel. (Cruel, but easy.)
@amin @sotolf @kabel42 @mirabilos @thedoctor
That's why I use good old C-x M-c M-spacebarheat ;)
@mirabilos @thedoctor @kabel42 @sotolf @amin
ksh got started in... 1983? That's not legacy? XD
