0

Examples from: Linux Journal article

The first two examples work, but the third does not, as expected from the article. Can someone explain why? I have tried on both Ubuntu 22.04.1 and RHEL9, with the same result.

My screen:

[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]$ 

But as extended regex, the third example works:

[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]$   

0 Answers0