'grep matches exact string or with wildcard
I want to search the content of a file that could contain for example:
name1
name2
name3
...
...
name10
name11
...
...
the search should match the string if it doesn't have a wildcard (*). for example :
grep -w name1 filename
it returns exactly what I want:
file1 #ignores file10 & file11 as no wildcard used
but when I use the same command but with wildcard (*), as follows:
grep -w name1* filename
it also returns file1 only. without file10 and file11. How can I match the string exactly as the first case and when a (*) is used it should include the others?
Note: I have seen some answers suggested using .* instead of * it worked but for my application the input is coming always in the form of * not .*
thank you in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
