shell切分字符串到数组

解决方法1:

#!/bin/=’,分字符串,,,=${  element  $

解决方法2:

#!/bin/bash user="aa:bb is ok:/home/work"i=1while((1==1))do  split=`echo $user|cut -d ":" -f$i`   if [ "$split" != "" ]; then     ((i++))     echo $split   else    break  fi done

http://shenzhen.offcn.com/

滇ICP备2023000592号-31