5
votes
1answer
613 views

Why do I have to escape a “dot” twice?

I know that we can escape a special character like *(){}$ with \ so as to be considered literals. For example \* or \$ But in case of . I have to do it twice, like \\. otherwise it is considered ...
3
votes
2answers
136 views

Can I make grep treat escaped multiline as a single line?

How can I make tools like grep treat multilines escaped with a backslash as a long single line? Let's say I have some files that looks like this: testvar=test1 \ test2 \ test3 ...
3
votes
3answers
5k views

How can I pass strings with single quotes to grep?

My desired outcome is the following: to recursively search a directory looking for a given string in all found files. The following command is my usual port of call: find ./ | xargs grep -ns 'foobar' ...
3
votes
1answer
1k views

Escaping of meta characters in basic/extended posix regex strings in grep

Is it possible to escape all meta characters of a string inside a variable before passing it to grep? I know similar question has been asked before on SE (here) and also a good explanation here, but I ...
4
votes
1answer
1k views

How can I match the page break character in a regular expression?

Nano calls it ^L, but of course, typing something like $ grep -v "^\^L" file doesn't work. Its unicode codepoint is 000C. How can I match it in a regular expression?