I tried to use the
grep command to search for a string like
-R in a file. But the command thinks, that I am trying to hand over an option like
-i for ignore case.
Try to escape the characters
grep \\-R myfile.txt:
$ touch test.txt $ echo "-R" >> ./test.txt $ cat test.txt -R $ grep \\-R ./test.txt -R
-e option for
grep is for explicitly saying "the next argument is the pattern":
grep -e -R file
The above would search for line matching
-R in the file called
-e option may occur multiple times on the command line, and
grep will use all the given patterns (you will get the lines back that matches any of the patterns).