I run the following on sun Solaris (its run 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 which the same option on sun Solaris as the option grep -o
(to match string capture)
lidia
The findstr command is a Windows grep equivalent in a Windows command-line prompt (CMD). In a Windows PowerShell the alternative for grep is the Select-String command.
The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern. The pattern that is searched in the file is referred to as the regular expression (grep stands for global search for regular expression and print out). Syntax: grep [options] pattern [files]
To search for all the lines of a file that do not contain a certain string, use the -v option to grep . The following example shows how to search through all the files in the current directory for lines that do not contain the letter e.
Grep is a Linux / Unix command-line tool used to search for a string of characters in a specified file. The text search pattern is called a regular expression. When it finds a match, it prints the line with the result. The grep command is handy when searching through large log files.
Solaris grep doesn't seem to have such an option. If you just need this to run on some solaris boxes, perhaps they got 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?
Sun's^W^WOracle's grep
doesn't do that. You need to download the GNU grep version, preferably from sunfreeware.com.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With