m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/bash.md
diff options
context:
space:
mode:
Diffstat (limited to 'bash.md')
-rw-r--r--bash.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/bash.md b/bash.md
index 8877982..432bc5e 100644
--- a/bash.md
+++ b/bash.md
@@ -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