wiki/help/linux/bash/data_manipulation/array.md

11 lines
424 B
Markdown
Raw Normal View History

# array operations.
```bash
local A=( foo1 bar1 foo2 bar2 foo3 bar3 ) # initialization.
local first=${A[0]} # first element.
local last=${A[-1]} # last element.
local from2toEnd=${A[@]:2} # all arguments starting from 2nd.
local from2to3=${A[@]:2:1} # 1 argument from 2nd.
local fromLast3toLast1=${A[@]: -3:2} # space before - is required.
```