mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-05 14:27:51 +02:00
Add example for default value
This commit is contained in:
@@ -5,6 +5,7 @@ contributors:
|
|||||||
- ["Max Yankov", "https://github.com/golergka"]
|
- ["Max Yankov", "https://github.com/golergka"]
|
||||||
- ["Darren Lin", "https://github.com/CogBear"]
|
- ["Darren Lin", "https://github.com/CogBear"]
|
||||||
- ["Alexandre Medeiros", "http://alemedeiros.sdf.org"]
|
- ["Alexandre Medeiros", "http://alemedeiros.sdf.org"]
|
||||||
|
- ["Denis Arh", "https://github.com/darh"]
|
||||||
filename: LearnBash.sh
|
filename: LearnBash.sh
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -45,6 +46,10 @@ echo '$VARIABLE'
|
|||||||
echo ${VARIABLE/Some/A}
|
echo ${VARIABLE/Some/A}
|
||||||
# This will substitute the first occurance of "Some" with "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:
|
# Bultin variables:
|
||||||
# There are some useful builtin variables, like
|
# There are some useful builtin variables, like
|
||||||
echo "Last program return value: $?"
|
echo "Last program return value: $?"
|
||||||
|
Reference in New Issue
Block a user