该篇文章也是我在网上找的,现在我在努力学习数组,所以就想多了解一下,现在先收藏了,等有时间了就好好的消化一下,O(∩_∩)O哈哈~
一 shell数组操作模拟队列queue或者栈stack
http://www.tech-recipes.com/rx/911/queue-and-stack-using-array/
here is a series of operation on array,we can use these functions to implement a queue or stack that can help us more
push:
array=(“${array[@]}” $new_element)
pop:
array=(${array[@]:0:$((${#array[@]}-1))})
shift:
array=(${array[@]:1})
unshift
array=($new_element “${array[@]}”)
<

本文介绍了如何利用bash shell数组模拟队列和栈,包括push、pop、shift、unshift等操作,并提供了一个删除数组元素的函数。此外,还分享了创建shell数组及使用技巧,如定义、读取、赋值、删除等基本操作,以及分片和替换等高级用法。
最低0.47元/天 解锁文章
306

被折叠的 条评论
为什么被折叠?



