根据逗号分割字符串
#!/bin/bash string="hello,shell,haha" #与/之间与分割的字符 ,另外/后有一个空格不可省略 array=(${string//,/ }) for var in ${array[@]} do echo $var done