2 ms·
As noted in the article, I'm suggesting that the shell itself should able to handle searching a stream for NULs, without this roundabout way of doing things:
by chubot 9y ago
As noted in the article, I'm suggesting that the shell itself should able to handle searching a stream for NULs, without this roundabout way of doing things:
count-nul() {
# -o puts every match on its own line. (grep -o -c doesn't work.)
od -A n -t x1 | grep -o '00' | wc -l
}
You can do this in Python or Perl, but it's not a stretch for the shell to do it directly.
- falsedan 9y agoAnd I’m saying, this isn’t a feature I feel the lack of in bash. If I’m working with non-text data, I’ll move to a language with better handling of complex data structures like perl & explicitly handle concurrency myself. To be clear: oil has to be a compelling alternative to perl, not bash.