mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Added string length example
This commit is contained in:
parent
f39df1da09
commit
462f94b967
@ -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"}
|
||||
|
Loading…
Reference in New Issue
Block a user