shell 数组【了解一下】
2024-08-25 22:44:53
数组编程
#!/bin/bash
# array
soft=(
php
mysql
nginx
)
# 输出第一个
echo ${soft[0]}
# 输出所有
echo "This soft total ${soft[@]}"
# 输出数量
echo "This soft count ${#soft[@]}"
# 删除一个元素
unset soft[2]
echo "This soft total ${soft[@]}"
# 临时替换
echo ${soft[@]/php/java}
echo "This soft total ${soft[@]}"
运行结果
# /bin/bash array.sh
php
This soft total php mysql nginx
This soft count 3
This soft total php mysql
java mysql
This soft total php mysql
最新文章
- linux下安装nodejs
- Json数据的学习
- 9.3---魔术索引(CC150)
- android: 从相册中选择照片
- 修正magento快速搜索返回结果不准确
- <;javascript搞基程序设计>;笔记2015-9-25
- 【HDOJ】1987 Decoding
- 02将代码开源到github(不会使用github的来看看吧)
- deque,list,queue,priority_queue
- Effective Java 第三版——39. 注解优于命名模式
- netty 之 telnet HelloWorld 详解
- SpringBoot自动配置原理
- 3.CNN-卷积神经网络推导
- [转]Angular4首页加载慢优化之路
- C#字节数组与字符串转换
- Java并发编程:volatile关键字解析zz
- Apache-配置、测试和调试
- xshell 利用密钥登录
- AnyVal与AnyRef
- react学习笔记1之声明组件的两种方式