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