I run the following on Sun Solaris — it runs OK on Linux but not on 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 . . .
My question is which option on Sun Solaris does the same task as the option grep -o
(to match string capture) on Linux?
Advertisement
Answer
Solaris grep doesn’t seem to have such an option. If you just need this to run on some Solaris boxes, perhaps they have GNU grep installed? (E.g. this one has it under /usr/local/gnu/bin/grep
).
If you need this to run under any Solaris, you cannot use grep. Perhaps sed and awk can be used?