grep command on Solaris 9

淺唱寂寞╮ 提交于 2019-12-20 07:31:41

问题


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


回答1:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!