sed: string between single qoutes

I want to put an capital E infront of every string. It is important that I use sed.

Such that

(260,'\"$40 a Day\"',2002,'Color','USA','','2000100002',131,6.1,'2002-04-24')

becomes

(260,E'\"$40 a Day\"',2002,E'Color',E'USA',E'',E'2000100002',131,6.1,E'2002-04-24')

I have tried

sed "s/'.*'/E&/g"

but it only puts an E infront of the first string!

Regards Kim

Upvotes: 0

Views: 84

Answers (2)

ooga
ooga

Reputation: 15501

The greedy matching of * is matching from the first single quote all the way to the very last one. Try this instead:

sed "s/'[^']*'/E&/g"

As John1024 warns above, this will not work if escaped single-quotes are allowed.

Upvotes: 1

sat
sat

Reputation: 14949

Another sed,

sed "s/,'/,E'/g"

Upvotes: 1

Related Questions