Linux命令行与shell脚本(14)--在函数中使用数组
来源:互联网 发布:js是面向什么的? 编辑:程序博客网 时间:2024/06/07 09:47
数组变量和函数
- 传递数组给函数
function testit(){ local new_array; new_array=(`echo $@`); echo "The new array value is: ${new_array[*]}";}myarray=(1 2 3 4 5 6);echo "The original array is ${myarray[*]}";testit ${myarray[*]}
- 函数返回一个数组
function arraydblr(){ local origarray; local newarray; local elements; local i origarray=(`echo "$@"`); newarray=(`echo "$@"`); elements=$[ $# - 1 ]; for (( i = 0; i <= $elements ; i++ )) { newarray[$i]=$[ ${origarray[$i]} * 2 ] } echo ${newarray[*]}}myarray=(1 2 3 4 5);echo "The original array is :"${myarray[*]};arg1=`echo ${myarray[*]}`;result=(`arraydblr $arg1`);echo "The new array is: ${result[*]}"
0 0
- Linux命令行与shell脚本(14)--在函数中使用数组
- Linux命令行与shell脚本(13)--在函数中使用普通变量
- Linux命令行与shell脚本(9)--函数参数
- Linux命令行与shell脚本(15)--sed使用
- Linux命令行与shell脚本(16)--gawk使用
- 8、在Shell脚本中使用函数
- Linux命令行与shell脚本(12)--控制脚本
- Linux中shell脚本使用函数
- Linux命令行与shell脚本(4)--Linux文件权限
- Linux命令行和shell脚本编程-函数
- 在Shell脚本中处理命令行参数
- Linux命令行与Shell脚本编程(续)
- Linux命令行与Shell脚本编程(续2)
- Linux命令行与shell脚本(1)--常见目录名称
- Linux命令行与shell脚本(2)--常用命令
- Linux命令行与shell脚本(3)--环境变量
- Linux命令行与shell脚本(6)--软件包安装
- Linux命令行与shell脚本(8)--结构化命令
- Hibernate反向工程
- Application回收重启程序
- Android Studio导入framework.jar等系统jar包方式
- 2017版的pycharm注册码
- eclipse中 jetty启动maven web项目 ClassNotFoundException net.sf.json.JSONObject
- Linux命令行与shell脚本(14)--在函数中使用数组
- 浅谈HTML5的FormData对象
- UIImageView 渲染模式改变Image的渲染颜色
- Kingbase连接情况查询
- shell脚本编写规范
- Type Syntax error, insert ")" to complete Expression
- 属于自己的刷新控件
- 链表去重
- Machine Learning第六讲[应用机器学习的建议] --(一)评估学习算法