我已经试过洞这个我自己,但我非常失败,但是这基本上就是我想在SH(#!/ bin/sh的!)来实现:检查字符串的大小,并根据大小,操纵它?
须藤代码
SOMEVAR="VALUE"
if [ $SOMEVAR.length > 5]
then
# Take the first 5 characters of the string and add "HIS" to the end of them, assigning this new value to the SOMEVAR variable.
else
#just add "HIS" to the end of the string
fi
如果有人可以告诉我如何实现这一点,将不胜感激,我已经尝试使用$ {#SOMEVAR}> 5和$ {SOMEVAR:0:5}但这个dosnet为我工作。
感谢
你真的用“上海”(Bourne Shell中,一个老线厂商的Unix平台上)?或者你想用bash或ksh或者?祝你好运。 – shellter