P
P
polger2021-05-10 14:18:17
linux
polger, 2021-05-10 14:18:17

How to find a plain text string using grep?

Find a line in a file. The string can be in the form of a regular expression or even consist of any characters.
I tried this: The -F parameter allows you to interpret the search query as a string, but the hyphens at the beginning spoil everything. grep thinks this is a parameter for it and throws an error. Escaping in regular expressions seems very complicated to me. Since the search string can consist of any number of any characters. How to get out of the situation?
grep -x -F --max-count=1 "--ma.y3[4]$%#$^" file



Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BorLaze, 2021-05-10
@polger

Try adding two minuses after the list of flags:
grep -x -F --max-count=1 -- "--ma.y3[4]$%#$^" file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question