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

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

问题描述

我在 Solaris 9 上遇到了 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 主机

1.2.3.4 主机-MY

1.2.3.4 host-MY

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

I'd like to grep the line contains host string only (not the other line that contain host-MY)

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

I use: grep -Fxq host /etc/hosts

但是我收到了

grep: 非法选项 -- F

grep: illegal option -- F

grep: 非法选项 -- q

grep: illegal option -- q

grep: 非法选项 -- x

grep: illegal option -- x

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

in spite of the fact that this options I can find in grep manual on my Solaris machine

推荐答案

您可能没有调用好的 grep 可执行文件.运行 which grep 以了解您正在运行哪个.在我的 Solaris 机器上,官方 grep 位于:

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

我的 Solaris 机器上的手册页同时提到了 /usr/bin/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天全站免登陆