2022-06-25 11:42:44 +02:00
|
|
|
---
|
|
|
|
title: Fish
|
2022-11-19 15:25:20 +01:00
|
|
|
visible: true
|
2022-06-25 11:42:44 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
[toc]
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-06-25 11:42:44 +02:00
|
|
|
## For loop
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-06-25 11:42:44 +02:00
|
|
|
### Iterating over number sequence
|
2023-02-23 14:48:51 +01:00
|
|
|
|
2022-06-25 11:42:44 +02:00
|
|
|
`for i in (seq 1 10); echo $i; end`
|
2023-02-23 14:48:51 +01:00
|
|
|
Output:
|
|
|
|
|
2022-06-25 11:42:44 +02:00
|
|
|
```
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
|
|
```
|
|
|
|
|
|
|
|
If you want all numbers to be padded to equal lengths use the `-w` flag with `seq`
|
|
|
|
`for i in (seq -w 1 10); echo $i; end`
|
2023-02-23 14:48:51 +01:00
|
|
|
Output:
|
|
|
|
|
2022-06-25 11:42:44 +02:00
|
|
|
```
|
|
|
|
01
|
|
|
|
02
|
|
|
|
03
|
|
|
|
04
|
|
|
|
05
|
|
|
|
06
|
|
|
|
07
|
|
|
|
08
|
|
|
|
09
|
|
|
|
10
|
2022-11-19 15:25:20 +01:00
|
|
|
```
|