diff options
author | Marcin Chrzanowski <m@m-chrzan.xyz> | 2021-09-10 13:12:17 +0200 |
---|---|---|
committer | Marcin Chrzanowski <m@m-chrzan.xyz> | 2021-09-10 13:12:17 +0200 |
commit | 77a2f6f8a656d1ca56ce9b2f96e610d54133cfa6 (patch) | |
tree | bc1d7984fb3a56c13c47a9791dc2999338821ded | |
parent | 01e06cdcffdb01f9018798414ad580896bcb8544 (diff) |
Add bash arrays
-rw-r--r-- | bash.md | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -53,3 +53,27 @@ Don't interpolate variables: cat << 'EOF' > file bla bla EOF + +## Arrays + +Declaring indexed arrays: + + declare -a name + +Associative arrays: + + declare -A name + +Assignment: + + array=([bla]=foo [ble]=bar...) + +All values: + + ${array[*]} # one word, elements separated with first character of $IFS + ${array[@]} # separate words when double quoted + +All keys: + + ${!array[*]} + ${!array[@]} |