bash
This demonstrates the usage of positional arguments in Bash scripts and functions.
$1 # first argument passed to a script or function $# # the number of arguments passed to a script or functio $* # all the arguments passed to a script or function, treating them as a single string $@ # all the arguments passed to a script or function, treating them as an array
bash internaldata manipulationspositional argumentspositional argument
bash
This demonstrates prefix name expansion in Bash to list all variables that start with a specified prefix.
prefix_a=one prefix_b=two echo ${!prefix_*} # all variables names starting with `prefix_` # => prefix_a prefix_b
bash internaldata manipulationsstring manipulation and expansionsparameter expansionprefix expansion
bash
This demonstrates case conversion using parameter expansion in Bash.
str="HELLO WORLD!" echo "${str,}" #=> "hELLO WORLD!" (lowercase 1st letter) echo "${str,,}" #=> "hello world!" (all lowercase) str="hello world!" echo "${str^}" #=> "Hello world!" (uppercase 1st letter) echo "${str^^}" #=> "HELLO WORLD!" (all uppercase)
bash internaldata manipulationsstring manipulation and expansionsparameter expansioncase conversion
bash
This demonstrates various Bash shell options (shopt
) for controlling globbing behavior, including case-insensitivity, recursive matching, and handling of non-matching patterns.
shopt -s nullglob # Non-matching globs are removed ('*.foo' => '') shopt -s failglob # Non-matching globs throw errors shopt -s nocaseglob # Case insensitive globs shopt -s dotglob # Wildcards match dotfiles ("*.sh" => ".foo.sh") shopt -s globstar # Allow ** for recursive matches ('lib/**/*.rb' => 'lib/a/b/c.rb')
bash internalshell configuration and customizationglobbing options