shell判断变量字符串路径的结尾和开头是否包含/

已邀请:

begin=`echo ${polar_data:0:1}`
end=`echo ${polar_data:0-1}`

if [ "$begin" != '/' ]; then
echo "${polar_data} must be the full path"
exit 1
fi

if [ "$end" != '/' ]; then
echo "${polar_data} must end with /"
exit 1
fi

要回复问题请先登录注册