By reading this question, I have discovered that GNU grep
has a -X
option which expects an argument. Strangely, it is mentioned neither in the man page nor in the info page.
Looking at the source code, there is that comment right in the middle of the --help
output:
/* -X is deliberately undocumented. */
Looking further, it appears that the -X matcher
option sets the engine used for the regexp, matcher
being one of grep
, egrep
, fgrep
, awk
, gawk
, posixawk
and perl
(as of version 2.25).
Some of those values are strictly identical to existing options (namely grep -G
, grep -E
, grep -F
and grep -P
). On the other hand, the three awk
variants have no corresponding options.
Does someone know what is the actual purpose of this option, especially with one of the awk
regexp engines? Can someone tell me why it is purposely not documented?
Best Answer
Its purpose is to provide access to the various matchers implemented in GNU
grep
in one form or another, in particular AWK matchers which aren’t available otherwise, probably for testing purposes (see bug 16481 which discusses adding thegawk
andposixawk
matchers).However it is currently buggy, which is the reason why it’s documented as being undocumented:
A follow-up asked for the comment to be added, and provided a bit more background on the
-X
option:which Stepan did shortly thereafter.