Skip to content

Commit e53e0a3

Browse files
authored
Update array arguments (#3)
1 parent ab947f4 commit e53e0a3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

content/008-bash-arrays.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ echo ${my_array[1]}
2626
echo ${my_array[-1]}
2727
```
2828

29-
* This would output the total number of elements in the array, in our case it is `4`:
29+
* As with command line arguments using `@` will return all arguments in the array, as follows: `value 1 value 2 value 3 value 4`
3030

3131
```bash
3232
echo ${my_array[@]}
3333
```
3434

35-
Make sure to test this and practice it at your end with different values.
35+
* Prepending the array with a hash sign (`#`) would output the total number of elements in the array, in our case it is `4`:
36+
37+
```bash
38+
echo ${#my_array[@]}
39+
```
40+
41+
Make sure to test this and practice it at your end with different values.

0 commit comments

Comments
 (0)