Reputation: 51
Within bash, I'm trying to using grep to search input string in multiple files. As I have different patterns matching I use a variable which is filename with wildcards.
I found it didn't interpret the wildcards because it interpreted just as question mark.
pattern="Report????.log"
grep -ciF $input "$pattern"
If I just write
grep -ciF $input Report????.log
this definitely works.
So is there a way to solve this if I still want to use variable with wildcards?
Upvotes: 0
Views: 119
Reputation: 3530
Remove the quotes in $pattern
and it will work.
pattern="Report????.log"
grep -ciF $input $pattern
Upvotes: 2