mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-22 12:57:01 +00:00
add variable
get the first character of the variable
This commit is contained in:
parent
283d52b361
commit
54a00b2569
10
README.md
10
README.md
@ -838,9 +838,17 @@ var="some string"
|
||||
echo ${#var}
|
||||
# 11
|
||||
```
|
||||
##### get the first character of the variable
|
||||
```bash
|
||||
var="some string"
|
||||
echo ${var%%"${var#?}"}
|
||||
#s
|
||||
```
|
||||
##### replacement (e.g. remove the first leading 0 )
|
||||
```bash
|
||||
${var[@]#0}
|
||||
var="0050"
|
||||
echo ${var[@]#0}
|
||||
#050
|
||||
```
|
||||
|
||||
##### replacement (e.g. replace 'a' with ',')
|
||||
|
Loading…
Reference in New Issue
Block a user