ITPub博客

首页 > 应用开发 > IT综合 > shell切分字符串到数组

shell切分字符串到数组

IT综合 作者:ii_chengzi 时间:2019-10-07 17:44:34 1 删除 编辑

解决方法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/

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31543790/viewspace-2658973/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2018-06-26

  • 博文量
    264
  • 访问量
    342575