Solaris 9上的grep命令 [英] grep command on Solaris 9

查看:167
本文介绍了Solaris 9上的grep命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Solaris 9上遇到了一个grep命令的奇怪行为。
例如,我有一个包含两行代码的主机文件:

1.1.1.1 host

1.2.3.4 host-MY



我想grep这行只包含主机字符串(而不是包含host-MY的其他行)

我使用:
grep -Fxq主机/ etc / hosts



但我收到

grep:非法选项-F

grep:非法选项 - - q



grep:非法选项 - x



尽管我可以找到这个选项在我的Solaris机器上的grep手册中

解决方案

您可能没有调用好 grep 可执行文件。
运行,其中grep 知道您正在运行哪一个。
在我的Solaris机器上,官方 grep 位于:

 > grep 
/ usr / xpg4 / bin / grep

我的Solaris机器上的手册页指的是 / usr / bin / grep / usr / xpg4 / bin / grep 。只有最新版本支持这些选项。


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.

这篇关于Solaris 9上的grep命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆