#!/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) |

0

上一篇:将博客搬至CSDN

下一篇:没有了

热门推荐