add variable

get the length of variable
This commit is contained in:
onceupon 2018-04-10 14:57:51 +08:00 committed by GitHub
parent b310c4acbe
commit 430cfb08ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -826,6 +826,13 @@ for line in $(cat myfile); do echo $line; read -n1; done
#'bar' #'bar'
# double/single quotes around single quotes make the inner single quotes expand variables # double/single quotes around single quotes make the inner single quotes expand variables
``` ```
##### get the length of variable
```bash
var="some string"
echo ${#var}
# 11
```
##### replacement (e.g. replace 'a' with ',') ##### replacement (e.g. replace 'a' with ',')
```bash ```bash
{i/a/,} {i/a/,}