I need to grep a string from a file, which contains '`' character. How to achieve this? Wrapping string around " and ' doesn't work.
Asked
Active
Viewed 1,114 times
-1
-
Can you give some information about the underlying operating system and shell you are using (e.g. default Ubuntu 14.04 and its "Terminal" application or whatever it is called). – Felix Aug 20 '15 at 19:14
-
1\` is not an apostrophe, it's a backtick. – melpomene Aug 20 '15 at 19:29
-
@melpomene Thank you for clarification english language :) – Piotr Aug 20 '15 at 20:13
-
in CentOS, grep -rP and \x60 as '`' did the job. – Piotr Aug 21 '15 at 00:10
1 Answers
0
To grep from a file which has a backtick in its name you can put a backspace in front of it. The same works for finding a string that holds the backtick. e.g.:
grep \` stupid\`filename

Pieter Bruegel the Elder
- 667
- 4
- 15
-
-
That's right. Double quotes ("), however, do not work. – Pieter Bruegel the Elder Aug 20 '15 at 22:32
-
Thanks, however, my file was OK, I was looking for a string quoted by backtick. – Piotr Aug 21 '15 at 00:13
-
-
@melpomene Well, you are almost correct. However, if you have simple text file than this statement doesn't apply. Ie. in mysql dump file you have tables names wrapped by backticks. – Piotr Aug 21 '15 at 08:55