I need to egrep string that is unknown before execution, and what I will get through the shell variable (shell bash, if that matters). The problem is that the string will contain special characters such as braces, spaces, periods, slashes, etc.
If I know a string, I can avoid special characters one at a time, but how can I do this for the entire string?
Running a line using a sed script to prefix each special character with \ might be an idea, I still need rtfm how such a script should be written. I do not know if there are other, better options.
I read re_format(7) , but it seems that there is no such thing as "take the whole next line as a literal" ...
EDIT: to avoid false positives, I should also add newline detection to the template, for example. egrep '^myunknownstring'
Luke404
source share