Results 1 to 3 of 3
I have used SED before, but at a basic level...
I have a text file with several lines for example..
FRED 123
BERT88
BERT89
BERT90
BERT101
FRED 234
JIM1
JIM2 ...
- 07-14-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 4
Can I do this in SED??
I have used SED before, but at a basic level...
I have a text file with several lines for example..
FRED 123
BERT88
BERT89
BERT90
BERT101
FRED 234
JIM1
JIM2 etc
I want to take the number just behind FRED and stick it on the front of all subsequent lines, so the output is
FRED 123
123BERT88
123BERT89
123BERT90
123BERT101
FRED 234
234JIM1
234JIM2 etc
I am trying to get my head round whether using the hold space can accomplish this.. but I really need to know if I am on to a loser with SED for this..
- 07-14-2010 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Try it with awk:
Code:awk '/FRED/{n=$2;print;next}{print n $0}' file
- 07-15-2010 #3Just Joined!
- Join Date
- Mar 2010
- Posts
- 4
Thanks... I thought I might need to awk it...


Reply With Quote