lid*_*dia 5 linux grep solaris options
我在sun Solaris上运行以下命令(在Linux上运行正常)但在sun Solaris上运行不正常
name="(WORD = (TCPIP = (PROTOCOL = TCP)(WORD = ALIAS_NAME)(PORT = 10234))"
echo $name | grep -o "(WORD = (TCPIP = (PROTOCOL = TCP)(WORD = ALIAS_NAME)(PORT = 10234))"
grep: illegal option -- o
Usage: grep -hblcnsviw pattern file . . .
Run Code Online (Sandbox Code Playgroud)
我的问题在sun Solaris上作为选项的相同选项grep -o(匹配字符串捕获)
利迪娅
Solaris grep 似乎没有这样的选项。如果您只需要在某些 Solaris 机器上运行它,也许它们安装了 GNU grep?(例如,这个位于 下/usr/local/gnu/bin/grep)。
如果您需要在任何 Solaris 下运行它,则不能使用 grep。也许可以使用 sed 和 awk ?