Can I sed on an environment variable, even if I don't need to actually change said (hah, hah) variable? Something like:
sed s/xyz/abc/g $myvar
Then if I did need to change $myvar I could maybe do:
$myvar=`sed s/xyz/abc/g $myvar`
Can I sed on an environment variable, even if I don't need to actually change said (hah, hah) variable? Something like:
sed s/xyz/abc/g $myvar
Then if I did need to change $myvar I could maybe do:
$myvar=`sed s/xyz/abc/g $myvar`
So myvar is holding data?
I normally pipe through sed....
echo "$myvar" | sed ......
That's what I was hoping to avoid
With zsh, ksh93 and bash:
printf "%s\n" "${myvar//xyz/abc}"
With zsh you have vared
And if you insist to use sed:
with here string (if your shell supports them):
sed 's/xyz/abc/g'<<<$myvar
Otherwise you can use here document.