From c9a282d08fb1f8670fa328e0e7cdb8801382b88a Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Wed, 18 Dec 2013 09:37:27 +0100 Subject: [PATCH] Add example for default value --- bash.html.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bash.html.markdown b/bash.html.markdown index 1f1c32c0..815290dd 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -5,6 +5,7 @@ contributors: - ["Max Yankov", "https://github.com/golergka"] - ["Darren Lin", "https://github.com/CogBear"] - ["Alexandre Medeiros", "http://alemedeiros.sdf.org"] + - ["Denis Arh", "https://github.com/darh"] filename: LearnBash.sh --- @@ -45,6 +46,10 @@ echo '$VARIABLE' echo ${VARIABLE/Some/A} # This will substitute the first occurance of "Some" with "A" +# Default value for variable +echo ${FOO:-"DefaultValueIfFOOIsMissingOrEmpty"} +# This works for null (FOO=), empty string (FOO=""), zero (FOO=0) returns 0 + # Bultin variables: # There are some useful builtin variables, like echo "Last program return value: $?"