extract string from varying delimiter line

Hi

I have lines like this

a=1, b=2, c=3,
a=1, d=4, e=5, b=225,

I need to extract the b=nnn... value. I dont know how many other entries will be before and after it in each line. Ive tried a basic line like
awk '/b=/, $NF ~ /,/ ' myfile.txt
but I think that it doesnt care which comma it picks.

I to begin the selection with b= and end it with the NEXT comma after b=

Any ideas?
Thanks.

please post ur desired output...

desired output would be
b=2
b=225

didnt test it but try...

awk -F, '{for(i=1;i<NF;i++){if($i ~ /b=[0-9]*/) print $i}}' inputfile

Fantastic. Dedicate that brain to science upon your demise, may it be far into the future. ! :slight_smile: . It worked like a dream

grep -o "b\([=0-9]\)\+" inputfile