Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Effects of grep -o when it's not available Post 302268977 by earnstaf on Tuesday 16th of December 2008 03:48:30 PM
Old 12-16-2008
Quote:
Originally Posted by joeyg
Code:
> testval="this is"
> echo "wow this is a test" | sed "s/$testval/~&~/" | tr "~" "\n" | grep "$testval"
this is

Is that what you are looking for?
That is clever, but I don't know if it works for my situation, which is this:

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.
 

6 More Discussions You Might Find Interesting

1. Cybersecurity

Effects on data size during encrypted transfer

Hi There, I wonder if any one can help me. I want to transfer a file from one site to another over an encrypted link. I want to know if there will be any imcrease in the data that will travel on the link? For example, I want to transfer a 1 GB file from one site to another, using an encrypted... (4 Replies)
Discussion started by: ahmerin
4 Replies

2. Red Hat

3D effects on RHEL6 OC

Hello, I just installed RHEL6 OC on my T61p. It's great! Just for fun I'd like to use some fancy cool Desktop effects. I tried to enable 3D Desktop effects from OC Welcome Center but it gave me error message: Accelerated 3D graphics is not available. Desktop effects require hardware 3D support.... (7 Replies)
Discussion started by: susja
7 Replies

3. Red Hat

3d effects in rhel6

I installed rhel 6.0 in my laptop but it is not upporting 3d graphics of rhel6 and i am getting an error message "Accelerated 3d graphics not available Desktop effects require hardware 3D support." my laptop is dll studio 1558 and my graphic card is ATI Radeon 5470 with 1 gb dedicated ram. (6 Replies)
Discussion started by: nileshgupta
6 Replies

4. Red Hat

Effects of /etc/fstab file!

Hi Folks! I accidentally overwrote in /etc/fstab file. Can you guys please tell me, what impact it would have created, when I restarted the machine(RHEL6). I executed this command : # blkid /dev/vda5 > /etc/fstab (17 Replies)
Discussion started by: nixhead
17 Replies

5. Ubuntu

Ubuntu encryption and its effects

How will Full Disk encryption effect how open-source software is compiled and run using ubuntu 14.04. Are there alternatives that are recommended? Thank you :). (0 Replies)
Discussion started by: cmccabe
0 Replies

6. What is on Your Mind?

Remove filter effects from downloaded videos?

Does anyone know a way to remove filter effects from videos downloaded from YouTube or elsewhere, preferably with software that runs in Windows 7? Thank you in anticipation. (1 Reply)
Discussion started by: quadphonic
1 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 03:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy