regex - How to make grep interpret a search expression ignoring all special characters -
i'd search html string contains characters interpreted grep special characters. there flag or command tell grep interpret characters in search string literal characters, not special characters?
perfect world:
grep --ignorespecial '<a href="/abc/def" class="foo.bar"/>'
yes! use grep -f
.
from man grep
:
-f, --fixed-strings
interpret pattern list of fixed strings, separated newlines, of matched. (-f specified posix.)
test
$ cat hello <a href="/abc/def" class="foo.bar"/>my href</a> <a href="/abc/def/ghi" class="foo.bar"/> $ grep -f '<a href="/abc/def" class="foo.bar"/>' <a href="/abc/def" class="foo.bar"/>my href</a>
or more bash codes:
$ cat hello <a href="/abc/def" class="foo.bar"/>my href</a> is/ $line ^codes * yeah $ grep 'this is/ $line ^codes * yeah' # no -f, no matches $ $ grep -f 'this is/ $line ^codes * yeah' # -f, matches is/ $line ^codes * yeah
Comments
Post a Comment