need help with extracting text blocks in unix

July 17, 2009 at 01:03:22
Specs: UNIX
Hello,

I have a little problem. In a textfile I have something like this:

user1:
parameter1 = value

user2:
parameter1 = value
parameter2 = value
parameter4 = value

user3:
parameter2= value
parameter3 = value

(the length of the user-name and parameter-name is different)

Now I want to extract the parmeters and values for each user block. So I can say wich user has wich parameter.

But I donĀ“t know how.

Can you help me please?

Thanks!


See More: need help with extracting text blocks in unix

Report •


#1
July 17, 2009 at 05:50:01
echo "enter :"
read user
awk -v user=$user 'BEGIN{ RS=""}$0 ~ user{    print  } ' file

GNU win32 packages | Gawk


Report •

#2
July 29, 2009 at 06:21:54
Hi,

thnaks it works great. ;-)


Report •

Related Solutions


Ask Question