If I use a lot of backslashes, can I do any regular expression with grep? So far, it seems so.

I mean, without grep -E also. So just "grep regex file", with many backslashes where needed.

有帮助吗?

解决方案

man egrep

"In addition, two variant programs egrep and fgrep are available. egrep is the same as grep -E. fgrep is the same as grep -F. Direct invocation as either egrep or fgrep is deprecated, but is provided to allow historical applications that rely on them to run unmodified."

-E means extended regular expressions, still man egrep: "grep understands three different versions of regular expression syntax: “basic,” “extended” and “perl.” In GNU grep, there is no difference in available functionality between basic and extended syntaxes. In other implementations, basic regular expressions are less powerful. The following description applies to extended regular expressions; differences for basic regular expressions are summarized afterwards. Perl regular expressions give additional functionality, and are documented in pcresyntax(3) and pcrepattern(3), but may not be available on every system."

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top