Extracting from a string based on keywords

Extracting from a string based on keywords

Post by Mark Fergusso » Sat, 30 Aug 1997 04:00:00



Hello all,

I realize this is probably a simple question, but I find the man on awk
pretty dismal. (Solaris 2.5).

Basically, how can I extract everything after of a specific keyword in a

string ? (any method will do)
I have:
...<string> ...=....<string>..val=<string>...

I want to extract everything after "val=" and assign it to a variable.

How can this be done ?  (The number of words before the "val=" may not
be consistant).

Any comments would be greatly appreciated.

Thanks in advance.

--
==========================================================
 Mark Fergusson   Voice:     (+27)-31-5602440
 Dimension Data    Fax:        (+27)-31-848525
 PO Box 20713                   Cellulal:  082-771-8519

 4016
 South Africa         Web:      http://www.didata.co.za
==========================================================

 
 
 

Extracting from a string based on keywords

Post by Kuntal Daftar » Sat, 30 Aug 1997 04:00:00



> file test.txt cotains:
> word word word val= this is the test

> the following command will pass the test:

>  cat test.txt|cut -d= -f2

> which is most likely a "useless use of cat", but it works.

i guess most "useless uses of cat" work. but they are
useless :-)

cut -d= -f2 test.txt does the trick

but this will remove the 'val=' also...

--
Kuntal M. Daftary   Cisco Systems Inc
Ph: 408 527 9789    170 W. Tasman Dr