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
...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
@rl_dane Those are so not comparable!
@sotolf @thedoctor @rl_dane @mirabilos
Mm, not really though? ripgrep is meant for bulk grepping of files
@sotolf @thedoctor @rl_dane @mirabilos
I mostly just use it to run rg TODO and see all the spots in a codebase I marked as still needing work.
@amin @sotolf @thedoctor @mirabilos
Why is ripgrep better than just grep -R?
@kabel42 @amin @sotolf @thedoctor @mirabilos
Interesting! I wonder what kind of algorithmic optimizations (as opposed to compiler optimizations) they're using to do that, and if regular (GNU/BSD) grep could do the same.
Because I'll wear clown shoes and a tutu before changing to a "rewrite the world in rust!" utility 😂
@kabel42 @rl_dane @amin @sotolf @thedoctor eww, it’s not even a drop-in then…
(For not-a-drop-in, I found pcregrep interesting. Sadly, Debian recently dropped it, but in the versions which don’t have pcregrep any more, you can use grep -P for many use cases. pcre2grep is not a drop-in for pcregrep either…)
@kabel42 @mirabilos @amin @sotolf @thedoctor
"transpiling" from PCRE to normal regex sounds deliciously cursèd. XD
@rl_dane @sotolf @kabel42 @thedoctor @amin TINSTA "normal" regex. Do you mean POSIX ERE?
Not possible because PCRE is not a regular expression language. (Chomsky hierarchy.) Unless you skip some features anyway.
Also, POSIX semantics for longest-match suck.
@mirabilos @sotolf @kabel42 @thedoctor @amin
Yes, I did mean POSIX RE and ERE.
Ok, now we're getting into liguistics and my hair is standing on end 😄
@mirabilos @sotolf @kabel42 @thedoctor @amin
Yes. I think the last pedant bus has left for the day, though. ;)
@mirabilos @sotolf @kabel42 @thedoctor @amin
yay for me 😂