Skip to content
Advertisement

how to escape single quotes in grep

I found a few questions here similar to this but they are not quite identical.

I want to grep for the text 'true' format in certain files.

How do I do it?

Not sure how to escape the single quotes around true.

Advertisement

Answer

Just wrap the string within double quotes:

grep "'true' format" your_file

Test

$ cat a
this is 'true' format
and this is true formatting
test

$ grep "'true' format" a
this is 'true' format
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement