I have a directory that contains the following
Applications  Desktop   Documents   Downloads   Dropbox (Personal)
Google Drive   Library   Movies   Music   Pictures   Public
I am trying to learn how to use grep by playing around with it, and uncovered the following surprising result when I piped the output of ls into grep:
ls | grep D* returns:
grep: Documents: Is a directory
grep: Downloads: Is a directory
grep: Dropbox (personal): Is a directory
grep: Google Drive: Is a directory
But when I do ls | grep Do* I get the following:
grep: Downloads: Is a directory
Why doesn't ls | grep Do* return the Documents folder as well? As in:
grep: Documents: Is a directory
grep: Downloads: Is a directory
Lastly, this question is different than the questions and answers here and here. I'm not looking for a way to solve this problem by switching to awk or passing flags to grep: instead, I'm looking to understand the underlying behavior of grep.
 
    