I faced a strange behavior of a grep command on Solaris 9. For example , I have a host file with two lines:
1.1.1.1 host
1.2.3.4 host-MY
I'd like to grep the line contains host string only (not the other line that contain host-MY)
I use: grep -Fxq host /etc/hosts
but I receive
grep: illegal option -- F
grep: illegal option -- q
grep: illegal option -- x
in spite of the fact that this options I can find in grep manual on my Solaris machine
You're probably not calling the good grep
executable.
Run which grep
to know which one you are running.
On my Solaris box, the official grep
is in:
> which grep
/usr/xpg4/bin/grep
The man page on my Solaris box refers to both /usr/bin/grep
and /usr/xpg4/bin/grep
. Only the latest supports these options.
来源:https://stackoverflow.com/questions/5245973/grep-command-on-solaris-9