Neapolitan23
asked on
How To Append Text to Variable & SED
I want to add ' in front and behind my variable and replace one character inside.
Here is my input: peter:chris
Here is my expected output: 'peter-chris'
I have tried, but my code is failing. My echo prints nothing. Code attempt attached.
Appreciate your help.
Here is my input: peter:chris
Here is my expected output: 'peter-chris'
I have tried, but my code is failing. My echo prints nothing. Code attempt attached.
Appreciate your help.
if [ -n "$string" ]
then
set string = `echo "'"$string"'" | sed "s/:/-/"`
echo $string;
fi
Which shell are you using, and how did you set $string before running that code?
ASKER
bash shell.
string="$1" (value from the command line)
string="$1" (value from the command line)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.