> 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.
The regexp in nawk considers also the case when the variables are empty, if needed.
Edit: I used your code on a single record and it worked like a charm. Is there any way I can get that same output on multiple records?
Edit2: Disregard the below... I kept your RS=' ' the same and ran the code on an entire 400 record file, and it did output different variables for each record, but with no formatting. I need it to give a newline at the end of each individual record. Ideas?
Thanks for that.. looks like the right idea. How would I implement that if I have a file with about 400 records like the one above? Each new record is started by the "acl add" line. I tried the following with no success...
Added a ! to the start of each record:
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)
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)
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)
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)
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)
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)