Computing.Net > Forums > Programming > need help with extracting text blocks in unix

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

need help with extracting text blocks in unix

Reply to Message Icon

Name: Hennig
Date: July 17, 2009 at 01:03:22 Pacific
OS: UNIX
Subcategory: General
Comment:

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!



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: July 17, 2009 at 05:50:01 Pacific
Reply:

echo "enter :"
read user
awk -v user=$user 'BEGIN{ RS=""}$0 ~ user{    print  } ' file

GNU win32 packages | Gawk


0

Response Number 2
Name: Hennig
Date: July 29, 2009 at 06:21:54 Pacific
Reply:

Hi,

thnaks it works great. ;-)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: need help with extracting text blocks in unix

Need help with algorithm!! www.computing.net/answers/programming/need-help-with-algorithm/594.html

Need help with WinXP batch script www.computing.net/answers/programming/need-help-with-winxp-batch-script/13165.html

Need help with an SQL join query www.computing.net/answers/programming/need-help-with-an-sql-join-query/13358.html