diff options
author | Marcin Chrzanowski <m@m-chrzan.xyz> | 2025-01-08 16:18:50 +0100 |
---|---|---|
committer | Marcin Chrzanowski <m@m-chrzan.xyz> | 2025-01-08 16:18:50 +0100 |
commit | b7c68da88eec95f7705c3f4d1f0b7ba3b64abb74 (patch) | |
tree | 7f65459b6cdbc8e9e9c74ee2e829e28ec72ada39 | |
parent | f435f7d40f2fd503ca6649b417997e418edc3697 (diff) |
Add bash things
-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 |