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!

text formatting 1

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
PL
I have following input text:

Code:
[COLOR=#ff0000]group0[/color]          heresomestring          [COLOR=#ff0000]1[/color]
name                   dAaxd1
name alias        member4
name                   dAaxd2
name alias        member14
[COLOR=#ff0000]group1[/color]          heresomestring          [COLOR=#ff0000]1[/color]
name                   ck1
name alias        member0
name                   ck2
name alias        member1
name                   ck3
name alias        member2
name                   ck4
name alias        member3
[COLOR=#ff0000]group2[/color]          heresomestring          [COLOR=#ff0000]2[/color]
name                   dBaxd1
name alias        member5
name                   dBaxd2
name alias        member15
[COLOR=#ff0000]group3[/color]          heresomestring          [COLOR=#ff0000]2[/color]
name                   cl1
name alias        member6
name                   cl2
name alias        member7
name                   cl3
name alias        member8


Each "group" in this file I need to convert to get output (example of expected output for group0 and a part of group1):

member4 dAaxd1 group0 1
member14 dAaxd2 group0 1
member0 ck1 group1 1
member1 ck2 group1 1
...


thank you in advance
Tom.
 
A starting point:
Code:
awk '$2=="alias"{print $3,name,group,digit;next}$1=="name"{name=$2;next}{group=$1;digit=$NF}' /path/to/input

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top