$ for num in {1..3}; do > echo $num > executed 1 2 3
Notice that it’s additionally doable to make use of brace growth a number of instances in the identical loop. Notice the usage of outer and inside braces.
$ echo {{1..3},{7..11}} 1 2 3 7 8 9 10 11
Substring manipulation
There are a number of methods to extract substrings in bash scripts. One of many best is to a bash command like this:
$ goal="my cat Bella" $ echo ${goal:7:6} Bella
You need to use a command just like the echo command proven under to capitalize (exchange) the primary letter in a string.
$ identify="joseph" $ echo "${identify/j/J}" Joseph
Bash instructions wrap-up
This cheat sheet for scripting in bash offers command examples together with explanations of how these instructions work. Feedback and options are welcome.