Originally Posted by nicomoresi
Sorry for the inconvenience (I'm new).
Started as a Linux consulting and changed to *NIX
glad you got it solved. Since it has been suggested that sed might be an appropriate tool
I would like to convey some thoughts on the use of 'sed' to emulate 'grep -io':
With GNU-sed available you could do something like this
sed -n 's/\(match\|alternate\)/\1\n/i;s/.*\(\(match\|alternate\)\n\)/\1/I;T;P;D' file
The problem when you do not have GNU-sed is the 'I' or 'i' flag at the end of the 's' command.
This tells sed to match case-insensitive. So it is likely that you do not have this option on Solaris.
You can bypass this by using the 'y' command; you will lose capitalization, though
sed -n 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
s/\(match\|alternate\)/\1\n/;s/.*\(\(match\|alternate\)\n\)/\1/;ta;b;:a P;D' file
If one is restricted to posix options only then you can't even use the logical '|' operator.
The second sed does not yield any results. However, I see that you used
sed -e "s/.*\(Cisco\|Motorola\|Arris\).*/\1/"
If this did return some matches then this suggests that Solaris-sed is somewhere between posix and GNU. If this is the case then maybe you have even case-insensitive matching; i.e. you can use the 'i' or 'I' flag at the end of the 's' command.
Finally, a posix only solution:
sed -n --posix 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
If you run this on the sample data I provided in a previous post
then you will see that you lose capital letters and that the results are not in order.
As I already stated, I do not have Solaris. So if you have some spare time on your hands and like to have some "fun" with sed then you can venture into exploring the limitations of Solaris-sed and determine for yourself if it is worth the trouble.
If you do so then some feedback would be nice, so that we might be able to suggest more appropriate Solaris-sed solutions in the future.