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