${string::N}提取前N个字符,${string:N}提取N个之后的字符 # cat ./test.sh #!/bin/bash test=1234567898453613025 num_test=`echo ${#test}` num=$[num_test/4 + 1 ] for i in `seq $num` do echo -ne "${test::4}" test=`echo ${test:4}` echo done # ./test.sh 1234 5678 9845 3613 025 转载请保留固定链接: https://linuxeye.com/program/1565.html |