gpt4 book ai didi

fish - 如何在 fish shell 中获取数组大小?

转载 作者:行者123 更新时间:2023-12-04 22:18:22 25 4
gpt4 key购买 nike

有没有办法获得 fish shell 中的数组大小?

我手头的确切问题是我想对除第一个以外的所有数组元素进行一些操作。所以我试图找到大小,以便我可以从 2 循环到 $array_size。

如果不可能,有什么替代方法?

最佳答案

count将打印元素的数量。但是如果你只想跳过第一个元素,你可以使用 slices :

> set arr one two three
> echo $arr
one two three
> echo $arr[2..-1]
two three

关于fish - 如何在 fish shell 中获取数组大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50009360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com