test.sh
#!/bin/bash string="hello,shell,split,test" array=(${string//,/ }) for var in ${array[@]} do echo $var done
输出
bogon:conf macname$ awk '{print length($0)}' test.sh 11 33 24 1 22 2 12 4
参考:
https://www.jb51.net/article/121290.htm