![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ksh pattern matching | ripat | Shell Programming and Scripting | 5 | 02-10-2008 01:44 PM |
| help need for pattern matching | HIMANI | UNIX for Dummies Questions & Answers | 10 | 01-22-2008 04:30 AM |
| pattern matching | mercuryshipzz | Shell Programming and Scripting | 4 | 01-14-2008 08:01 PM |
| pattern matching in an if-then | lumix | Shell Programming and Scripting | 4 | 12-14-2007 01:25 PM |
| Pattern matching sed | leemjesse | Shell Programming and Scripting | 3 | 03-23-2005 01:06 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Pattern Matching
How to print the words with matching pattern. GREP lists the lines matching given pattern. But I want those words that matches the pattern
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Please read the man page carefully. -o option is there
echo " this is grep test" | grep -o "test" test -o, --only-matching Show only the part of a matching line that matches PATTERN. |
|
#3
|
|||
|
|||
|
-o option in grep is not there. I am using MKS toolkit that executes Unix shell command in windows environment. Any other way?
|
|
#4
|
|||
|
|||
|
but -o option is not available in grep under solaris
-o option is not a standard option to grep |
|
#5
|
|||
|
|||
|
I don't have access to solaris machine right now. If I can recall correctly there are 2 executables for grep in Solaris. Second one should be under /usr/xpg/bin or /usr/xpg4/bin/grep
If not then check to see if egrep is there in your system ( which egrep). Last edited by vish_indian; 07-17-2006 at 04:44 AM. |
|
#6
|
|||
|
|||
|
both grep and egrep utilities both searches for the pattern with their own reserved differences in usage
man egrep Quote:
and the non-availability of option -o is for both and not just for the /usr/bin/grep |
|
#7
|
|||
|
|||
|
You might have to use awk then.
awk '/pat/{print $x}' filename where x is the field no. assuming pattern always occurs in the same field. |
|||
| Google The UNIX and Linux Forums |