![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VMGL brings 3-D effects to VMs | iBot | UNIX and Linux RSS News | 0 | 12-05-2008 04:10 PM |
| Keynote 2: Which transition and build effects can be played on my computer? | iBot | OS X Support RSS | 0 | 11-14-2008 12:20 AM |
| Final Cut Pro: "AE Effects Error: Unable to find plug-in" warning when opening some p | iBot | OS X Support RSS | 0 | 11-05-2008 01:10 AM |
| Culture gaps and herd effects - ZDNet | iBot | UNIX and Linux RSS News | 0 | 10-08-2007 05:00 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Effects of grep -o when it's not available
I'm on a Solaris box that doesn't have -o as an option for grep (trying to return match only). Is there any way to get this functionality without the -o option? I've tried both sed and awk doing something like: Code:
echo "this is a test" | awk '/test/' or echo "this is a test | sed '/test/p' but those match on the whole line, just as grep does without a -o. Ideas? edit: from the man page: Quote:
Last edited by earnstaf; 12-16-2008 at 03:44 PM.. |
|
||||
|
Quote:
Code:
> echo "this is a test" | grep -o test > test or > echo "this is a test" | grep -o "this is" > this is whereas without the -o, both of the above would return the whole line "this is a test" edit: syntax -- forgot quote
Last edited by earnstaf; 12-16-2008 at 03:47 PM.. |
|
||||
|
Quote:
I have a record that looks like: Code:
acl add name=ACL_RULE_NAME pos=400 action=allow agent=proxy authneeded=no \ dest=netgroup:destinations_ssh destburb=external nataddr= \ service=ssh source=ipaddr:1.2.3.4 sourceburb=internal \ comments='this is comments' \ lastchangedby='changed by the guy' I want to break that down and pull out just the stuff I care about, namely name, dest, destburb, source, sourceburb and service. I had planned on doing something like: Code:
while read line do source=`grep -o "source=.* "` dest=`grep -o "dest=.* "` echo "$source $dest" done I'm sure there is a more elegant or effective way... actually now that I'm looking at it that wont work since they records are on different lines... might have to use awk. However, I cant even get the idea in motion without grep -o. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|