Added second substring example

This commit is contained in:
Martin Nicholson 2018-01-16 15:27:30 +00:00
parent 70a36c9bd9
commit f39df1da09

View File

@ -16,6 +16,7 @@ contributors:
- ["Betsy Lorton", "https://github.com/schbetsy"] - ["Betsy Lorton", "https://github.com/schbetsy"]
- ["John Detter", "https://github.com/jdetter"] - ["John Detter", "https://github.com/jdetter"]
- ["Harry Mumford-Turner", "https://github.com/harrymt"] - ["Harry Mumford-Turner", "https://github.com/harrymt"]
- ["Martin Nicholson", "https://github.com/mn113"]
filename: LearnBash.sh filename: LearnBash.sh
--- ---
@ -76,6 +77,8 @@ echo ${Variable/Some/A} # => A string
Length=7 Length=7
echo ${Variable:0:Length} # => Some st echo ${Variable:0:Length} # => Some st
# This will return only the first 7 characters of the value # 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)
# Default value for variable # Default value for variable
echo ${Foo:-"DefaultValueIfFooIsMissingOrEmpty"} echo ${Foo:-"DefaultValueIfFooIsMissingOrEmpty"}