#!/bin/bash #太复杂了,别学我 for i in `cat nowcoder.txt` do b=${#i} if [[ $b < 4 ]] then echo $i; fi if [[ $b > 3 ]] then a=$(($b % 3)) if [[ $a = 1 ]] then sum1="" for ((a=-3;a>-b;a=a-3)) do sum=",""${i:a:3}" sum1="$sum""$sum1" done echo "1""$sum1" elif [[ $a = 2 ]] then sum1="" for ((a=-3;a>-b;a=a-3)) do sum=",""${i:a:3}" sum1="$sum""$sum1" done echo "12""$sum1" else sum1="" for ((a=-3;a>-b;a=a-3)) do sum=",""${i:a:3}" sum1="$sum""$sum1" done echo "123""$sum1" fi fi done