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

标签 fish

有没有办法获得 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/

相关文章:

bash - Bash 中 <<EOF 的 Fish 等价物是什么

config - 为fish shell指定不同的配置文件

shell - fish shell 提示: fish not reading fish_prompt. fish nor fish_right_prompt.fish

string - fish shell : validate if string contains substring

events - 如何在 Fish shell 中设置退出时运行的函数?

windows - 在 Windows 上使用 Bash 时如何在 Fish 中显示完整目录?

prompt - 在 Fish Shell 中获取当前目录(没有完整路径)

git - 使用 && 的 Fishshell 别名

fish shell 如何在后台启动进程的PID

python - 如何在 fish 中设置 PYTHONPATH?