diff options
Diffstat (limited to 'bash.html.markdown')
-rw-r--r-- | bash.html.markdown | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bash.html.markdown b/bash.html.markdown index e0c12f97..4c50c653 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -59,12 +59,14 @@ echo ${VARIABLE/Some/A} # This will substitute the first occurance of "Some" with "A" # Substring from a variable -echo ${VARIABLE:0:7} +LENGTH=7 +echo ${VARIABLE:0:LENGTH} # This will return only the first 7 characters of the value # Default value for variable echo ${FOO:-"DefaultValueIfFOOIsMissingOrEmpty"} -# This works for null (FOO=), empty string (FOO=""), zero (FOO=0) returns 0 +# This works for null (FOO=) and empty string (FOO=""); zero (FOO=0) returns 0. +# Note that it only returns default value and doesn't change variable value. # Builtin variables: # There are some useful builtin variables, like |