diff options
author | Martin Nicholson <recyclebing+github@gmail.com> | 2018-01-16 15:31:32 +0000 |
---|---|---|
committer | Martin Nicholson <recyclebing+github@gmail.com> | 2018-01-16 15:31:32 +0000 |
commit | 462f94b967d4814e57bb6836cfd9d13abd8f9ab7 (patch) | |
tree | 25908c0500f91307be5ec9c248e1804763c1b749 /bash.html.markdown | |
parent | f39df1da097f8718b375127ad04f2114c5c4e48d (diff) |
Added string length example
Diffstat (limited to 'bash.html.markdown')
-rw-r--r-- | bash.html.markdown | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bash.html.markdown b/bash.html.markdown index ed4fa54f..fa3c5ebe 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -77,8 +77,11 @@ echo ${Variable/Some/A} # => A string Length=7 echo ${Variable:0:Length} # => Some st # This will return only the first 7 characters of the value -echo ${Variable: -Length} -# This will return the last 7 characters (note the space before -Length) +echo ${Variable: -5} # => tring +# This will return the last 5 characters (note the space before -5) + +# String length +echo ${#Variable} # => 11 # Default value for variable echo ${Foo:-"DefaultValueIfFooIsMissingOrEmpty"} |