Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Effects of grep -o when it's not available Post 302269082 by rubin on Tuesday 16th of December 2008 09:02:32 PM
Old 12-16-2008
Given your sample with (n)awk you can do something like this:

Code:
$ cat file
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'


Code:
eval  `nawk '/source=[^ ]*/
             /sourceburb=[^ ]*/
             /dest=[^ ]*/
             /destburb=[^ ]*/
             /name=[^ ]*/
             /service=[^ ]*/' RS=' '  file`


Output:

Code:
$ echo $source
ipaddr:1.2.3.4
$ echo $service
ssh
$ echo $name
ACL_RULE_NAME
$ echo $destburb
external
$ echo $dest
netgroup:destinations_ssh
$ echo $sourceburb
internal

The regexp in nawk considers also the case when the variables are empty, if needed.
 

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
GREP(1) 						      General Commands Manual							   GREP(1)

NAME
grep - search a file for lines containing a given pattern SYNOPSIS
grep [-elnsv] pattern [file] ... OPTIONS
-e -e pattern is the same as pattern -c Print a count of lines matched -i Ignore case -l Print file names, no lines -n Print line numbers -s Status only, no printed output -v Select lines that do not match EXAMPLES
grep mouse file # Find lines in file containing mouse grep [0-9] file # Print lines containing a digit DESCRIPTION
Grep searches one or more files (by default, stdin) and selects out all the lines that match the pattern. All the regular expressions accepted by ed and mined are allowed. In addition, + can be used instead of * to mean 1 or more occurrences, ? can be used to mean 0 or 1 occurrences, and | can be used between two regular expressions to mean either one of them. Parentheses can be used for grouping. If a match is found, exit status 0 is returned. If no match is found, exit status 1 is returned. If an error is detected, exit status 2 is returned. SEE ALSO
cgrep(1), fgrep(1), sed(1), awk(9). GREP(1)
All times are GMT -4. The time now is 03:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy