【发布时间】:2011-03-22 22:16:53
【问题描述】:
我想获取 BSD dict 单词列表中每个单词的前两个字母,不包括那些仅以一个字母开头的单词。
没有一个字母的排除,它运行得非常快:
time cat /usr/share/dict/web2 | cut -c 1-2 | tr '[a-z]' '[A-Z]' | uniq -c > /dev/null
real 0m0.227s
user 0m0.375s
sys 0m0.021s
然而,在 '..' 上的 grepping 非常缓慢:
time cat /usr/share/dict/web2 | cut -c 1-2 | grep '..' | tr '[a-z]' '[A-Z]' | uniq -c > /dev/null
real 1m16.319s
user 1m0.694s
sys 0m10.225s
这是怎么回事?
【问题讨论】:
-
ʞɔıu,这一定是我见过的最酷的帐户名称之一。
标签: regex unix command-line grep