diff options
-rw-r--r-- | bash.md | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -66,6 +66,9 @@ Associative arrays: Assignment: + # Indexed + array=(foo bar "baz bom"...) + # Associative array=([bla]=foo [ble]=bar...) All values: @@ -78,6 +81,23 @@ All keys: ${!array[*]} ${!array[@]} +So looping: + + # Over values + for x in "${array[@]}"; do ... + # Over keys (0-based indices for indexed) + for x in "${!array[@]}"; do ... + + +Array size: + + ${#array[@]} + +Slice: + + # n elements starting at index i + ${array[@]:i:n} + ## Commandline arguments * `$#`: number of arguments. @@ -99,3 +119,13 @@ Positional arguments will have to be supplied after flag options (`command [options] <args>`): shift $((OPTIND-1)) + + +## Shell optional behavior/settings/options (`shopt` builtin) + + # Enable + shopt -s <option> + # Disable + shopt -u <option> + +* `nocaseglob`: glob matching is case insensitive |