How to insert single quote in a text line

Eclipse Eclipse ecl-sc1
March 1, 2010 at 12:05:50
Specs: Linux/Ubuntu
Friends,
I have a variable
Store_List= (00234,00445,00777,00445)
I want to use sed/awk in such a way that the Store_List becomes
( '00234' , '00445' , '00777' , '00445' ) and this new string should be stored in a variable called Store_List_new.
Precisely i want to insert space and single qote around each no.
I am not getting how to do this.

I will highly appreciate your help friends.
Thank you!


See More: How to insert single quote in a text line

Report •

#1
March 1, 2010 at 20:33:19
In this sed script, the first part replaces the left parenthesis with another parenthesis/quote, the second replaces the right parenthesis with another parenthesis/quote, and the third replaces each comma with a quote/comma/quote:

Store_List="(00234,00445,00777,00445)"

Store_list_new=$(echo "$Store_List"|sed -e "s/(/('/" -e "s/)/')/" -e "s/,/','/g")

echo "$Store_list_new"


Report •

#2
March 4, 2010 at 19:58:53
Hey nails,
Thanks a lot.
This worked...

Report •
Related Solutions


Ask Question