How to use 'grep' with characters like * and _?
8,991
There is a -F option:
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by POSIX.)
This will disable searching by regular expressions and interpreting characters like *
or .
. Example:
$ cat test
a**__
$ grep -F 'a**__' test
a**__
Related videos on Youtube
Author by
user203748
Updated on September 18, 2022Comments
-
user203748 over 1 year
I need to find some text in one or more files.
This is what I use:
grep -irI "hello" ~/
However, if I want to find a string containing characters like
*
or_
then these seem to be ignored.Let's say I want to search in all files for the string
a**__
.How can I do that? Many thanks - I just can't figure this out!