Add indirect expansion in bash.html.markdown

This commit is contained in:
oliv37 2020-04-20 20:35:47 +02:00 committed by Andrew Ryan Davis
parent 55ad60b7dd
commit 6955861bba

View File

@ -88,6 +88,11 @@ echo ${Variable: -5} # => tring
# String length # String length
echo ${#Variable} # => 11 echo ${#Variable} # => 11
# Indirect expansion
OtherVariable="Variable"
echo ${!OtherVariable} # => Some String
# This will expand the value of the OtherVariable
# Default value for variable # Default value for variable
echo ${Foo:-"DefaultValueIfFooIsMissingOrEmpty"} echo ${Foo:-"DefaultValueIfFooIsMissingOrEmpty"}
# => DefaultValueIfFooIsMissingOrEmpty # => DefaultValueIfFooIsMissingOrEmpty