1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-01-16 21:18:40 +01:00

Variable substr

This commit is contained in:
Justin Campbell 2014-02-28 11:24:45 -05:00
parent 31b5427774
commit 1b67b8f230

View File

@ -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