shellScript之数组操作5
来源:互联网 发布:广州恒大淘宝 编辑:程序博客网 时间:2024/06/14 11:27
#!/bin/bashcity=(nanjing alta Massachusetts marseilles)echo "Extracting substring"echo ${city[*]:0}#extracting from 0 to endecho ${city[@]:1}#extracting from 1 to endecho ${city[*]:3}#extracting from 3 to endecho ${city[@]:0:2}#extracting from 0 to 2echo echo "Remove substring"echo ${city[*]#M*a}#Remove the shortest substringecho ${city[@]##M*a}#remove the longest substringecho "Replacing substring"echo ${city[*]/M*s/Year}#replace the first substringecho ${city[*]//M*s/Year}#replace all the substring
结果:
~/script/shell_text $ ./10special_operatal_array.sh Extracting substringnanjing alta Massachusetts marseillesalta Massachusetts marseillesmarseillesnanjing altaRemove substringnanjing alta ssachusetts marseillesnanjing alta chusetts marseillesReplacing substringnanjing alta Year marseillesnanjing alta Year marseilles
阅读全文
0 0
- shellScript之数组操作5
- shellScript之数组操作1
- shellScript之数组操作2
- shellScript之数组操作3
- shellScript之数组操作4
- shellScript之数组操作6
- shellScript之数组操作7
- shellScript之位置参数
- shellScript之if_else语句
- shellScript之if_elif_else语句
- shellScript之case语句
- shellScript之for语句
- shellScript之while语句
- shellScript之while语句
- shellScript之util语句
- shellScript之break关键字
- shellScript之continue语句
- shellScript之select语句
- poj1065
- shellScript之数组操作4
- Liunx彩色进度条
- java关于hibernate如何基于注解创建联合主键
- C/C++程序的内存分配
- shellScript之数组操作5
- Django配置Ajax跨域调用/设置Cookie
- Android---广播
- iOS BASE64 编码 和HASH 哈希函数(散列函数) ~用户信息安全
- shellScript之数组操作6
- Spark转化算子和操作算子
- 安卓练习
- 微信公众号开发 配置服务器URL,验证Token
- 如何将公式中的参数转化成数字