mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-22 12:57:01 +00:00
Improve 'get the first character of variable
Thanks to Masta's command on Reddit
This commit is contained in:
parent
e553be01fc
commit
c2fc594db4
@ -1018,9 +1018,13 @@ echo ${#var}
|
|||||||
```
|
```
|
||||||
##### get the first character of the variable
|
##### get the first character of the variable
|
||||||
```bash
|
```bash
|
||||||
var="some string"
|
var=string
|
||||||
|
echo "${var:0:1}"
|
||||||
|
#s
|
||||||
|
|
||||||
|
#or
|
||||||
echo ${var%%"${var#?}"}
|
echo ${var%%"${var#?}"}
|
||||||
#s
|
|
||||||
```
|
```
|
||||||
##### remove the first or last string from variable
|
##### remove the first or last string from variable
|
||||||
```bash
|
```bash
|
||||||
|
Loading…
Reference in New Issue
Block a user