diff options
author | Justin Campbell <justin@justincampbell.me> | 2014-02-28 11:24:45 -0500 |
---|---|---|
committer | Justin Campbell <justin@justincampbell.me> | 2014-02-28 11:24:45 -0500 |
commit | 1b67b8f2304c1787d14bb26c817774b4b7aa2eac (patch) | |
tree | 8fd5835a17d15a1b81f369e5c893d2fadb5e5c27 | |
parent | 31b542777449d6a2a8bbd66a0e1cf570ea82e335 (diff) |
Variable substr
-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 |