grep metacharacter question.
1 Attachment(s)
Attachment 14302
Why does ls | grep sta* not display any result ? I don't understand how ls | grep sta*. works as well. From my understanding, it matches each literal s-t-a, matches 'a' literal zero or more times, and matches any character. Why is the match stat as shown in the screenshot ? Thanks. |
You need to put the search pattern between single or double quotes (or escape the *). If you do not do this the shell will expand sta* to status1 status2. This is done before control is handed over to the rest of the command, the command becomes
Code:
ls | grep stautus1 status2 These will work: Code:
ls | grep "sta*" |
Thanks alot. I totally forgotten that bash shell will expand some of those characters..
|
All times are GMT -5. The time now is 09:29 AM. |