From 462f94b967d4814e57bb6836cfd9d13abd8f9ab7 Mon Sep 17 00:00:00 2001 From: Martin Nicholson Date: Tue, 16 Jan 2018 15:31:32 +0000 Subject: [PATCH] Added string length example --- bash.html.markdown | 7 +++++-- 1 file 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"}