Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract data under a particular user name... 1

Status
Not open for further replies.

RVSachin

Technical User
Nov 12, 2001
77
IN
Hi,

I have a huge output file which contains data about some users.
Report for each user starts with the following line in the file.

Code:
[b]Detailed Report for User: <user name>[/b]

....some data...


[b]Detailed Report for User: <[COLOR=blue]USER NAME I AM INTERESTED IN[/color]>[/b]


....some other data...


[b]Detailed Report for User: <user name>[/b]


....some more data...


Note that the no. of lines under each user is never the same.
I need to extract only the data of a particular user from this file into a different file.
How can I do this in KSH?

Thanks,

RV
 
Something like this ?
Title="Detailed Report for User:"
UserName="USER NAME I AM INTERESTED IN"
inp="/path/to/input"
out="/path/to/output"
sed -n "/^$Title $UserName/,/$Title/p" $inp | sed '$d' >$out


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top