Hi,
I'm developing my first bash script and have made good progress but stuck at this point.
I've run sed on a text file to extract some data and have saved it into a variable e.g.
$blah
the variable contains emails as follows e.g.
<a@b.com> <b@c.com>
I'm now trying to edit the values in this variable so that if there is more than one email address, then they should be separated by commas instead of spaces.
I've currently got this far:
#$num is how many words there are in the variable
if (($num==1))
then
#insert sed command to put single mail address in ok (i will add this later)
else
#below i'm trying to substitute the spaces for commas but it's only adding #a comma to the last email address
blahnew=$(echo $blah | sed 's/[^ ].*/&,/g')
echo $blahnew
fi
so i get:
<a@b.com> <b@c.com>
,
Would appreciate any help please.