有关shell脚本的一些网站资源

常用的shell函数
http://www.intuitive.com/wicked/wicked-cool-shell-script-library.shtml

在这里有位大虾提供的资源,好诶
http://www.l3jane.net/websvn/wsvn/Factory/trunk/Shell/lib/?rev=2025#a4928e0d2a9c0a7bc89cf27975ac7ad62

shell数组的一些用法
摘自:http://yangdc.iteye.com/blog/276025

$ arr=(123 34 3 5)
$ echo $arr // 默认获取第一个元素
> 123
$ echo ${arr[1]} // 通过下标访问
> 34
$ echo ${arr[@]} // 访问整个数组 ,@或者* 获取整个数组
> 123 34 3 5
$ echo ${#arr[@]} // 获取数组的长度(最大下标) ,#获取长度 数组中是最后一个下标
> 3
$ echo ${#arr[3]} // 获取字符串长度
> 1
$ echo ${arr[@]:1:2} // 切片方式获取一部分数组内容
> 34 3
$ echo ${arr[@]:2} // 从第二个元素开始
> 3 5
$ echo ${arr[@]::2} // 到第二个元素
> 123 34

参考 http://www.tech-recipes.com/rx/642/bash-shell-script-accessing-array-variables/

array 的模拟操作
– http://www.tech-recipes.com/rx/911/queue-and-stack-using-array/
push:
array=(”${array[@]}” $new_element)

pop:
array=(${array[@]:0:$((${#array[@]}-1))})

shift:
array=(${array[@]:1})

unshift
array=($new_element “${array[@]}”)

function del_array {
local i
for (( i = 0 ; i < ${#array[@]} ; i++ ))
do
if [ "$1" = "${array[$i]}” ] ;then
break
fi
done
del_array_index $i
}

function del_array_index {
array=(${array[@]:0:$1} ${array[@]:$(($1 + 1))})
}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值