script required

The line is like this
+abc+def+mgh+ddsdsd+sa
i.e. words seperated by +. There is a plus in the beginning.

i want to conver this line to
abc, def, mgh, ddsdsd, sa

please provide the logic in the form of a shell script

Thanks in advance

Skyineyes,
Do not break the rules duplicating posts:

You will just make it more difficult for you to find a solution.
Give time to the members to work on the issue.

Sincere Appologies.

I felt that the earlier heading wasn't appropriate.

Not a problem.
Here is your solution:

sed 's/+//;s/+/,/g' input_file

You can try:

sed 's/+/,/g' filename | sed '1s/,//'

Hi

i am facing few problems with the above. let me rephrase the question

VALUE="+ABC+DEF+FGDh+YU+ghs+V"

i want VALUE to be like this

VALUE=" ABC, DEF, FGDH, YU, ghs, V "

i.e '+' to be replaced by ",<space>" except beginning. The initial + is to be replaced by blank.

Thanks

Just a modification to this is required

The initial string is like this
+abc+def+ghj+jkl+asd

Please note the + in the beginning also. i am having the whole string in a variable called VALUE and i want the new value of the varaiable to be
abc, def, ghj, jkl, asd

i.e removing starting + and repacing with ,<space> elsewhere with new string to be placed in the same varaiable.

Thanks

sed 's/+//;s/+/, /g' input_file

can you modify the code by assuming that the
instead of inout_file i have a varaiable which is holding all the line

VALUE="+ABC+DEF+MGH+THY+MGH+hjk+fyf"

the result should be stored back in VALUE

echo $VALUE | sed 's/+//;s/+/, /g'

try to do it yourself first, read a book, search the web, before posting. Here's a way using bash

VALUE="+ABC+DEF+MGH+THY+MGH+hjk+fyf"
VALUE=${VALUE:1}
VALUE=${VALUE//+/,}

B-A BA

VALUE="+ABC+DEF+MGH+THY+MGH+hjk+fyf"
VALUE=`echo "$VALUE" | sed 's/+//;s/+/, /g'`

Or (with some recent shells):

$ echo $ZSH_VERSION
4.3.2
$ str="+ABC+DEF+MGH+THY+MGH+hjk+fyf"
$ echo ${${str#?}//+/,}
ABC,DEF,MGH,THY,MGH,hjk,fyf

Thanks Folks
:slight_smile: