4 ms·
grep -c $pattern $file Half a second, unless I'm missing something? No objections at all to people building simpler UIs for common tasks. The classic Unix too
by NateEag 4y ago
grep -c $pattern $file
Half a second, unless I'm missing something?
No objections at all to people building simpler UIs for common tasks. The classic Unix tools are like table saws without labels or safety features - confusing and rightfully intimidating. You have to read the manual carefully to avoid chopping off digits.
... but they're also like table saws in that once you know them well and are comfortable with the usage patterns that protect you from the dangerous parts, they let you achieve things with a minimum of fuss and ceremony.
- IshKebab 4y ago> unless I'm missing something? Yes. $ echo aaaaaa | grep -c a 1
- NateEag 4y agoAh, thanks for clarifying. I did indeed misunderstand. grep -o $pattern $filename | wc -l would work in that case, I think. I did have to think for a minute to come up with that version. It was definitely still much faster for me than writing my own matching logic would have been, but that may well be different for other people.