我有以下代码......它主要是工作。除了我想将sed的结果写入变量newData。查看了很多其他帖子,但没有人能够为我工作。
newin="<font color='default'>Default Color has been choosen.</font>"
newData="$newin" | sed 's/</</g; s/>/>/g; s/<[^>]*>//g'
if [[ ${newin:0:1} == "<" ]]
then
#this echo works like it should
echo "$newin" | sed 's/</</g; s/>/>/g; s/<[^>]*>//g'
#this echo works like it should
echo "$newin"
#The variable newData does not seem to capture the data
newData=${newin} | sed 's/</</g; s/>/>/g; s/<[^>]*>//g'
echo "[$newdata]"
fi
输出:
Default Color has been choosen.
<font color='default'>Default Color has been choosen.</font>
[]