3 ms·
FWIW I wrote a related blog post: "Shell Pipelines Support Vectorized, Point-Free, and Imperative Style" http://www.oilshell.org/blog/2017/01/15.html http://w
by chubot 9y ago
FWIW I wrote a related blog post:
"Shell Pipelines Support Vectorized, Point-Free, and Imperative Style"
http://www.oilshell.org/blog/2017/01/15.html http://www.oilshell.org/blog/2017/01/15.html
I'm also writing a blog post right now that uses this real instance of point-free style:
count-nul() {
od -A n -t x1 | grep -o '00' | wc -l
}
# usage: count-nul < myfile.bin
The issue is that grep can't find NUL bytes, because argv is NUL-terminated. So you have to convert to hex, grep, and then count.