MaJ du 22-10-2020
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
##### Concaténer une chaine:
|
||||
#### Concaténer une chaine:
|
||||
|
||||
```bash
|
||||
upd+="$name "
|
||||
@@ -10,7 +10,7 @@ upd+="$name "
|
||||
|
||||
|
||||
|
||||
##### Trim une chaine:
|
||||
#### Trim une chaine:
|
||||
|
||||
1. sed
|
||||
|
||||
@@ -77,7 +77,7 @@ $ echo " Une chaine entourée d'espaces " | xargs -0
|
||||
|
||||
|
||||
|
||||
##### Longueur d'une chaine:
|
||||
#### Longueur d'une chaine:
|
||||
|
||||
```bash
|
||||
$ echo -n "Longueur de la chaine:" | wc -c
|
||||
@@ -93,11 +93,14 @@ $ echo ${#var}
|
||||
|
||||
|
||||
|
||||
##### Sous-chaine:
|
||||
#### Sous-chaine:
|
||||
|
||||
```bash
|
||||
$ string=abcABC123ABCabc
|
||||
|
||||
|
||||
# ${string:position:length}
|
||||
|
||||
$ echo ${string:0}
|
||||
abcABC123ABCabc
|
||||
|
||||
@@ -110,6 +113,13 @@ $ echo ${string:7}
|
||||
$ echo ${string:7:3}
|
||||
23A
|
||||
|
||||
# Obtenir les 2 premieres caractères:
|
||||
$ echo ${string:0:2}
|
||||
ab
|
||||
echo "$string" | awk '{print substr($0,0,2)}'
|
||||
ab
|
||||
|
||||
# Obtenir les 4 derniers caractères:
|
||||
$ echo ${stringZ: -4} # Notez l'espace
|
||||
Cabc
|
||||
|
||||
@@ -119,7 +129,7 @@ Cabc
|
||||
|
||||
|
||||
|
||||
Remplacement de sous-chaine:
|
||||
#### Remplacement de sous-chaine:
|
||||
|
||||
```bash
|
||||
$ string=abcABC123ABCabc
|
||||
|
||||
Reference in New Issue
Block a user