Issue
I have a file test.txt which contains this text data
# cat test.txt
*@=>*@
if I use grep to check if the string is in the file using this way
# grep "*@=>*@" test.txt
#
it returns nothing..
while if I grep a partial string search
# grep "*@=>" test.txt
# *@=>*@
it works correctly ..
Why in the first case do grep return nothing ?
Solution
The asterisk is special to grep
, it means "the previous token is repeated zero or more times". So >*
would match an empty string or >
or >>
etc.
To match an asterisk, backslash it in the pattern:
grep '\*@=>\*@' test.txt
(The first asterisk follows no token, so the backslash is optional.)
Answered By - choroba