trim()
{
trimmed=$1
trimmed=${trimmed%% }
trimmed=${trimmed## }
echo $trimmed
}
测试:
a=" x x "
b=" b b"
c="c c "
echo "=$a="
echo "=$b="
echo "=$c="
a=$(trim $a)
b=$(trim $b)
c=$(trim $c)
echo "=$a="
echo "=$b="
echo "=$c="
输出:
= x x =
= b b=
=c c =
=x=
=b=
=c=
相关热门文章
给主人留下些什么吧!~~
评论热议