Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[DUP] [CLOSED] sed regexp tamplate, covering 3 strings
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Off the Wall
View previous topic :: View next topic  
Author Message
cz0
Apprentice
Apprentice


Joined: 13 Jun 2005
Posts: 171
Location: /earth/russia/moscow

PostPosted: Wed Jul 01, 2009 6:56 am    Post subject: [DUP] [CLOSED] sed regexp tamplate, covering 3 strings Reply with quote

Hi folks!
I'm trying to make a tamplate for sed (s command) to replace 3 strings, looking like this:
;aaaaaaa
;bbbbbbb
;cccccccc

with strings like this:
aaaaaaa
bbbbbbb
ddddddd

but as it's 3 strings new line eatch, I have no clue how to make a tamplate. sed is called from bash script. I've tryed something like this:
Code:

cat filename | sed 's/;aaaaaaa{/*/*}/somthing'

and
Code:

cat filename | sed 's/;aaaaaaa{
/*
/*
}/somthing'

and bad luck :(
Can anybody help me as I'm already feeling sick of it.
Back to top
View user's profile Send private message
klixon
n00b
n00b


Joined: 14 Feb 2006
Posts: 39
Location: Holland

PostPosted: Wed Jul 01, 2009 9:18 am    Post subject: Reply with quote

s/;\(.\)/\1/
for readability: s|;\(.\)|\1|

the \1 in the replacement is a reference to the part between brackets in the regexp
_________________
Stand back, intruder, or I'll blast you out of space. I am Klixon and I don't want any dealings with you human lifeforms... I'm a cyborg!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Off the Wall All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum