4 ms·
This is an unfair comparison because you aren't using the same `grep` options. What your test shows is that `-cx` is not as efficient. On an x86 MBP: $ ti
by eddyg 4y ago
This is an unfair comparison because you aren't using the same `grep` options. What your test shows is that `-cx` is not as efficient.
On an x86 MBP:
$ time (for i in {1..100}; {grep -cx 'a..' /usr/share/dict/words}) >/dev/null
user=9.22s system=0.34s cpu=94% total=10.097
$ time (for i in {1..100}; {grep -e '^a..$' /usr/share/dict/words | wc -l}) >/dev/null
user=6.14s system=0.52s cpu=95% total=6.948
$ time (for i in {1..100}; {cat /usr/share/dict/words | grep -e '^a..$' | wc -l}) >/dev/null
user=6.29s system=0.80s cpu=100% total=7.024
- googlryas 4y agoI just used the grep command that OP mentioned in their cat abuse post.
- taskforcegemini 4y agoseems that OPs suggestion was only meant to make the command more concise