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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Text to Beginning of Selected Line 1

Status
Not open for further replies.

thunderkid

Technical User
Oct 26, 2000
54
US
I need to create new file as follows:
Input:

Seed 34567645
abc 0:01:41.0 2345 rt45
abc 0:01:42.0 2345 rt45
abc 0:02:03.0 2345 rt45
abc 0:03:04.0 2345 rt45
Seed 56753434
def 0:03:05.0 erte wfe5
def 0:03:06.0 erte wfe5
def 0:04:07.4 erte wfe5
def 0:05:08.5 erte wfe5

Desired output:

34567645 abc 0:01:41.0 2345 rt45
34567645 abc 0:01:42.0 2345 rt45
34567645 abc 0:02:03.0 2345 rt45
34567645 abc 0:03:04.0 2345 rt45
56753434 def 0:03:05.0 erte wfe5
56753434 def 0:03:06.0 erte wfe5
56753434 def 0:04:07.4 erte wfe5
56753434 def 0:05:08.5 erte wfe5

Help is greatly appreciated.

thunderkid
 
Try something like this:
Code:
awk '
/Seed /{Seed=$NF;next}
{print Seed " " $0}
' /path/to/input >output

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

Part and Inventory Search

Sponsor

Back
Top