Is there a way to grep
(or use another command) to find exact strings, using NO regex?
For example, if I want to search for (literally):
/some/file"that/has'lots\of"invalid"chars/and.triggers$(#2)[*~.old][3].html
I don't want to go through and escape every single "escapable". Essentially, I want to pass it through, like I would with echo
:
$ echo "/some/file\"that/has'lots\of\"invalid\"chars/and.triggers$(#2)[*~.old][3].html"
/some/file"that/has'lots\of"invalid"chars/and.triggers$(#2)[*~.old][3].html
使用fgrep
,它与grep -F
相同(匹配固定的字符串)。
Well, you can put the information you want to match, each in a line, and then use grep
:
grep -F -f patterns.txt file.txt
Notice the usage of the flag -F
, which causes grep
to consider each line of the file patterns.txt as a fixed-string
to be searched in file.txt .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.