当前位置:网站首页>Shell基本语法--数组
Shell基本语法--数组
2022-06-12 08:30:00 【__万波__】
shell数组只有一维数组, 没有多维数组
定义数组
# 定义数组只需要将内容用 () 括起来
# 数组元素没有类型限制
# 数组元素没有个数限制
arr_a=(1 2 3 "baidu.com")
arr_b=([0]=11 [5]=66)
访问数组成员
# 访问某一个成员
${arr_a[0]} ${arr_a[n]}
# 访问所有成员
${arr_a[@]} ${arr_a[*]}
获取数组成员个数
# 数组成员的个数, 求出的是数组中被赋值过的成员个数
${
#arr_a[@]} ${
#arr_a[*]}
# 注意, 下面的方式是获取第N个成员中保存的字符个数
${
#arr_a[n]}
向数组中追加成员
方式一: arr=(${arr[@]} def)
方式二: arr[6]="def" # 注意等号两遍不能有空格
修改数组成员
arr[2]="modified data" # 注意等到两边不能有空格
删除数组成员
unset arr[1] # 注意这里没有 $ 符号
边栏推荐
- Calling stored procedures in mysql, definition of variables,
- 处理异常数据
- 网站Colab与Kaggle
- Why should enterprises implement MES? What are the specific operating procedures?
- MPLS的原理与配置
- Hands on learning and deep learning -- a brief introduction to softmax regression
- 【新规划】
- [advanced pointer III] implement C language quick sorting function qsort & callback function
- 建立MES系统,需要注意什么?能给企业带来什么好处?
- call方法和apply方法
猜你喜欢

深拷贝与浅拷贝的区别

MATLAB image processing -- image transformation correction second-order fitting

安科瑞消防应急照明和疏散指示系统

数据库基础——规范化、关系模式

Prediction of COVID-19 by RNN network

Scope of bean

MATLAB image processing - cosine noise removal in image (with code)

【数据存储】浮点型数据在内存中的存储

Vision transformer | arXiv 2205 - TRT vit vision transformer for tensorrt

Hands on learning and deep learning -- Realization of linear regression from scratch
随机推荐
企业上MES系统的驱动力来自哪里?选型又该注意哪些问题?
报错:清除网站内搜索框中的历史记录?
ctfshow web 1-2
Hands on deep learning -- discarding method and its code implementation
(P14)overrid关键字的使用
Hands on deep learning -- Introduction to linear regression model
Website colab and kaggle
Install iptables services and open ports
【 pointeur avancé Ⅲ】 mise en œuvre de la fonction de tri rapide qsort& fonction de rappel en langage C
MYSQL中的锁的机制
FDA reviewers say Moderna covid vaccine is safe and effective for children under 5 years of age
Model compression | tip 2022 - Distillation position adaptation: spot adaptive knowledge distillation
(p25-p26) three details of non range based for loop and range based for loop
A brief summary of C language printf output integer formatter
(P13)final关键字的使用
What scheduling rules does the APS software have? What is the exception handling scheme?
MATLAB image processing -- image transformation correction second-order fitting
(P19-P20)委托构造函数(代理构造函数)和继承构造函数(使用using)
Hypergeometric cumulative distribution test overlap
How to write simple music program with MATLAB