2025-06-10 06:24:18 +02:00
|
|
|
# {
|
2025-02-20 00:02:20 -03:00
|
|
|
|
|
|
|
> Sintaxis de intérprete de comandos polivalente.
|
|
|
|
> Más información: <https://www.gnu.org/software/bash/manual/bash.html>.
|
|
|
|
|
|
|
|
- Aísla nombres de variables:
|
|
|
|
|
|
|
|
`echo ${HOME}work`
|
|
|
|
|
|
|
|
- Apuntala expandiendo secuencias:
|
|
|
|
|
|
|
|
`echo {1..3} {a..c}{dir1,dir2,dir3}`
|
|
|
|
|
|
|
|
- Comprueba si `variable` está definida antes de devolver el texto:
|
|
|
|
|
|
|
|
`echo ${variable:+variable is set and contains $variable}`
|
|
|
|
|
|
|
|
- Establece valores por defecto en caso de que `variable` no esté establecida:
|
|
|
|
|
|
|
|
`echo ${variable:-default}`
|
|
|
|
|
|
|
|
- Devuelve la longitud de `variable` en caracteres:
|
|
|
|
|
|
|
|
`echo ${#variable}`
|
|
|
|
|
|
|
|
- Devuelve un trozo de cadena:
|
|
|
|
|
|
|
|
`echo ${variable:3:7}`
|
|
|
|
|
|
|
|
- Expande recursivamente una `variable`:
|
|
|
|
|
|
|
|
`echo ${!variable}`
|
|
|
|
|
|
|
|
- Pone todos los caracteres en mayúsculas:
|
|
|
|
|
|
|
|
`echo ${variable^^}`
|