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.
*
and not.*
? (ie. though I wouldn't suggest it, could you just prepend.
to*
?) where does the input come from? do you have to usegrep
?foo
and the argument given to search for wasfo.
should that match or not?