#!/bin/sh
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=
阅读(3) | 评论(0) | 转发(0) |
相关热门文章
热门推荐