正規表現のアスタリスクは一致しません。なぜ?

正規表現のアスタリスクは一致しません。なぜ?

次の例: Linuxジャーナル記事

この記事で予想されるように、最初の2つの例は機能しますが、3番目の例は機能しません。誰かが理由を説明できますか? Ubuntu 22.04.1とRHEL9で同じ結果が得られました。

私の画面:

[primus@rhel9 sandbox]$ cat filename.doc 
The fast dog is fast.
The faster dogs are faster.
A sick dog should see a dogdoc.
This file is filename.doc.
[primus@rhel9 sandbox]$ grep "fast*" filename.doc 
The fast dog is fast.
The faster dogs are faster.
[primus@rhel9 sandbox]$ grep "dogs*" filename.doc 
The fast dog is fast.
The faster dogs are faster.
A sick dog should see a dogdoc.
[primus@rhel9 sandbox]$ grep "*.doc" filename.doc 
[primus@rhel9 sandbox]$ 
[primus@rhel9 sandbox]$ 

ただし、拡張正規表現では、3番目の例が機能します。

[primus@rhel9 sandbox]$  
[primus@rhel9 sandbox]$ egrep "*.doc" filename.doc  
A sick dog should see a dogdoc.  
This file is filename.doc.  
[primus@rhel9 sandbox]$ grep -E "*.doc" filename.doc   
A sick dog should see a dogdoc.  
This file is filename.doc.  
[primus@rhel9 sandbox]$   

ベストアンサー1

おすすめ記事