str="/home/gateman" if [ ${str:0:1} = "/" ]; then echo "yes'fi ${str:0:1} 中 0表示从第几个字符开始,1表示截取多长 转载于:https://www.cnblogs.com/nvd11/archive/2013/04/02/2996890.html