Operating System - HP-UX
1832877 Members
2272 Online
110048 Solutions
New Discussion

Re: How do I append chars in a single line via sed ?

 
SOLVED
Go to solution
Karsten Löperick
Valued Contributor

How do I append chars in a single line via sed ?

Hi all,

I have a problem with appending chars at the front and the end of a line that matches my search critria.
I want produce a output like this one
TEXT1 -> "TEXT1"
TEXT2 -> "TEXT2"

I tried this one with sed but it does not work correctly : sed "/TEXT1/s/(.*\/\"(.*)\"/ fileout
So sed should search TEXT1 an should replace the matched line by "TEXT1"

Thank you very much for any hints and helps

Karsten

Nothing is impossible
3 REPLIES 3
Andreas Voss
Honored Contributor
Solution

Re: How do I append chars in a single line via sed ?

Hi,

this shoud work:

sed 's/\(TEXT[0-9]\)/"\1"/' filein >fileout

Regards
mw_4
Frequent Advisor

Re: How do I append chars in a single line via sed ?

you cat edit file a like contents you want replace words..ie
#cat a
TEXT1..10..nth
sed 's/^/"/g' < a > c
sed 's/$/"/g' < c > a
#cat a
"TEXT1"

Good luck.!!
Step by step
Karsten Löperick
Valued Contributor

Re: How do I append chars in a single line via sed ?

Hi ,

Andreas answer is exactly what I want.
The new thing for me was the "\1" inside sed for replacing the whole Hold Space.

Thanks all for the quick reply and 10 points for Andreas.

Karsten
Nothing is impossible