Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图找到每个单词/usr/dict/words的字符与我的名字匹配的单词。我认为这会起作用:
/usr/dict/words
cat /usr/dict/words | grep "^[mason]\+$"
但它不打印任何东西。
话虽如此,当我跑步时:
cat /usr/dict/words | grep -v [A-Zbcdefghijlkpqrtuvwxyz]
我得到了正确的输出。我真的很困惑。这是怎么回事?
鉴于您没有查看/usr/share/dict/words,我假设您不在 linux 上。鉴于这+是对 的非标准扩展grep,我猜grep您正在使用的 无法识别+。尝试:
/usr/share/dict/words
+
grep
grep '^[mason][mason]*$' /usr/dict/words
或者
grep -E '^[mason]+$' /usr/dict/words