diff options
-rw-r--r-- | bash.html.markdown | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/bash.html.markdown b/bash.html.markdown index 70a3b52a..d5d08e9d 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -46,6 +46,10 @@ echo '$VARIABLE' echo ${VARIABLE/Some/A} # This will substitute the first occurance of "Some" with "A" +# Substring from a variable +echo ${VARIABLE:0:7} +# 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 |