1 #!/bin/bash
2
3 while true
4 do
5 read -p "please input a string:" string
6 if test -z string
7 then
8 echo "input error,please input a string again!"
9 continue
10 fi
11 len=${#string}
12 count=$((len/2))
13
14 for i in `seq $count`
15 do
16 last_i=$((len-i+1))
17 first=`echo $string | cut -c $i`
18 two=`echo $string | cut -c $last_i`
19 if ((first != two))
20 then
21 echo "no" && exit 1
22
23 fi
24 done
25 echo "yes"
26 done
shell脚本之检查回文
最新推荐文章于 2021-05-14 08:21:34 发布