Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using grep with a complex string

Tags:

grep

bash

I am looking in the content of several files for strings like:

(2E)-3-({5,6-dihydroxy-3-methyl-2-oxo-4-[(1E)-prop-1-en-1-yl]-2,3-dihydro-1-benzofuran

with grep, so I try to do:

grep -n "(2E)-3-({5,6-dihydroxy-3-methyl-2-oxo-4-[(1E)-prop-1-en-1-yl]-2,3-dihydro-1-benzofuran" *.data

but I get errors, probably due to the fact that the string is complex.

Are there additional grep options or another way for me to find this string in the files?

Thanks

like image 930
asdf Avatar asked Jun 20 '26 12:06

asdf


1 Answers

I don't have my man pages to hand, but have you tried grep -F? I think it turns off regexp and treats the pattern as a fixed string. fgrep does the same.

like image 91
Chowlett Avatar answered Jun 23 '26 03:06

Chowlett