commit
4eacb18b60
4
bash.md
4
bash.md
|
@ -3,7 +3,7 @@ title: Bash scripting
|
||||||
category: CLI
|
category: CLI
|
||||||
layout: 2017/sheet
|
layout: 2017/sheet
|
||||||
tags: [Featured]
|
tags: [Featured]
|
||||||
updated: 2018-11-19
|
updated: 2018-12-25
|
||||||
keywords:
|
keywords:
|
||||||
- Variables
|
- Variables
|
||||||
- Functions
|
- Functions
|
||||||
|
@ -122,6 +122,8 @@ echo ${name/J/j} #=> "john" (substitution)
|
||||||
echo ${name:0:2} #=> "Jo" (slicing)
|
echo ${name:0:2} #=> "Jo" (slicing)
|
||||||
echo ${name::2} #=> "Jo" (slicing)
|
echo ${name::2} #=> "Jo" (slicing)
|
||||||
echo ${name::-1} #=> "Joh" (slicing)
|
echo ${name::-1} #=> "Joh" (slicing)
|
||||||
|
echo ${name:(-1)} #=> "n" (slicing from right)
|
||||||
|
echo ${name:(-2):1} #=> "h" (slicing from right)
|
||||||
echo ${food:-Cake} #=> $food or "Cake"
|
echo ${food:-Cake} #=> $food or "Cake"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue