add notes about bash

This commit is contained in:
2022-04-01 10:35:39 +07:00
parent 031663a2d0
commit bdefa134e4

View File

@@ -135,3 +135,47 @@
### Web-servers ### Web-servers
* ssl config generation: https://ssl-config.mozilla.org/ * ssl config generation: https://ssl-config.mozilla.org/
# Script languages
## Bash
* замена значения переменной
```shell
a=1234
a=${a/12/FOO}
echo $a
FOO34
```
* объявление и вывод массива
```shell
arrayInt=(1 2 3 4 5)
# первый элемен
echo $arrayInt
1
# все элементы
echo ${arrayInt[@]}
1 2 3 4 5
# конкретный элемент
echo ${arrayInt[3]}
4
# идексы
echo ${!arrayInt[@]}
# размерность
echo ${#arrayInt[@]}
# присвоение массива из команды
arrayLs=($(ls))
# добавление элементов в конец массива
arrayInt+=(12 123 13)
```
* Разделитель значений для bash
```shell
echo $IFS
export IFS=;
unset IFS
```