shell script数组使用函数输出
#!/bin/bash
# array variable to function test function testit {
local newarray
newarray=("$@")
echo "The new array value is: ${newarray[*]}"
} myarray=( )
echo "The original array is ${myarray[*]}"
testit ${myarray[*]}
注意:
function testit { 中函数名 testit 和 { 中间是必须加上空格的。
myarray=( ) 中的 ( ) 两边不能加上双引号,等号两边不能加上空格的。
运行 sh test.sh 输出为:
The original array is
The new array value is:
shell script数组使用函数输出的更多相关文章
- Linux基础之-shell script(变量,运算符,流程控制,函数)
一.shell script Shell 脚本(shell script),是一种为shell编写的脚本程序.业界所说的shell通常都是指shell脚本,但读者朋友要知道,shell和shell s ...
- 03 . Shell数组和函数
Shell数组 简介 数组中可以存放多个值.Bash Shell 只支持一维数组(不支持多维数组),初始化时不需要定义数组大小(与 PHP 类似). 与大部分编程语言类似,数组元素的下标由0开始. S ...
- 声明数组变量/// 计算所有元素的总和/打印所有元素总和/输出/foreach循环/数组作为函数的参数/调用printArray方法打印
实例 下面是这两种语法的代码示例: double[] myList; // 首选的方法 或 double myList[]; // 效果相同,但不是首选方法 创建数组 Java语言使用new操作符来创 ...
- 101-PHP二维数组的元素输出三,封装成函数
<?php $arr=array(array(76,87,68), array(65,89,95), array(90,80,66), array(90,95,65),5,234,56,'Hel ...
- Linux&shell之高级Shell脚本编程-创建函数
写在前面:案例.常用.归类.解释说明.(By Jim) 使用函数 #!/bin/bash # testing the script function myfun { echo "This i ...
- 菜鸟教程之学习Shell script笔记(上)
菜鸟教程之学习Shell script笔记 以下内容是,学习菜鸟shell教程整理的笔记 菜鸟教程之shell教程:http://www.runoob.com/linux/linux-shell.ht ...
- linux shell 进阶篇、shell脚本编程-创建函数
使用函数 #!/bin/bash # testing the script function myfun { echo "This is an example of a function&q ...
- shell script简单笔记
变量 shell script是一种脚本语言,变量的定义是通过 myName=HYB 这样的形式定义的. 当存在空格时,可以通过双引号或单引号将其变为字符串.双引号不进行转义,单引号将内容进行转义为一 ...
- shell script的简单使用
shell script的简单介绍 shell变量 1.命名规则 命名只能使用英文字母,数字和下划线,首个字符不能以数字开头 中间不能有空格,可以使用下划线(_) 不能使用标点符号. 不能使用bash ...
随机推荐
- memcached启动参数
memcached启动参数描述: -d :启动一个守护进程, -m:分配给Memcache使用的内存数量,单位是MB,默认是64MB, -u :运行Memcache的用户 -l :监听的服务器IP地址 ...
- PHP编写的图片验证码类文件分享方法
适用于自定义的验证码类! <?php/* * To change this license header, choose License Headers in Project Propertie ...
- MyEclipse+Android 安装配置
1.先安装M有Eclipse 就是不断点:下一步下一步最后finish 激活:http://blog.my-eclipse.cn/myeclipse-2014-crack.html (该网站上 ...
- Cocos2dx lua 3D实例代码
用cocoside 创建一个项目 cocos2dx lua 项目即可 ,然后替换掉gamescene 就可以,具体效果还有函数的参数,相信大家一看就明白.简单说下ide 创建的 cocos lua 项 ...
- 第十一章 Android 内核驱动——Alarm
11.1 基本原理 Alarm 闹钟是 android 系统中在标准 RTC 驱动上开发的一个新的驱动,提供了一个定时器 用于把设备从睡眠状态唤醒,当然因为它是依赖 RTC 驱动的,所以它同时还可以 ...
- 证码识别--type1
证码识别--type1 从最简单的开始.主要 ...
- Linux内存模型
http://blog.csdn.net/sunyubo458/article/details/6090946 了解linux的内存模型,或许不能让你大幅度提高编程能力,但是作为一个基本知识点应该熟悉 ...
- python终端颜色设置
1.颜色定义说明 格式:\033[显示方式;前景色;背景色m 前景色 背景色 颜色 --------------------------------------- 30 40 黑色 31 41 ...
- 万年历---java版
程序难点 : 1. 每年每个月有多少天? 2. 每个月的1号是星期几? 3. 每年的2月份是多少天? 难点解析 : 1. 每年每个月除去1 3 5 7 8 10 12是31天以外, 其他月份(除去2月 ...
- ContentProvider官方教程(11)Calendar Provider、Contacts Provider、Storage Access Framework
Calendar Provider: guide/topics/providers/calendar-provider.html Contacts Provider: guide/topics/pro ...