2025-07-24 22:27:13 -06:00
|
|
|
# $
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
> Expand a Bash variable.
|
|
|
|
|
> More information: <https://gnu.org/software/bash/manual/bash.html#Shell-Variables>.
|
|
|
|
|
|
|
|
|
|
- Print a variable:
|
|
|
|
|
|
|
|
|
|
`echo ${{VARIABLE}}`
|
|
|
|
|
|
2025-07-24 22:27:13 -06:00
|
|
|
- Run variable contents as a command:
|
|
|
|
|
|
|
|
|
|
`${{VARIABLE}}`
|
|
|
|
|
|
2025-03-14 21:59:59 -06:00
|
|
|
- Print the exit status of the previous command:
|
|
|
|
|
|
|
|
|
|
`echo $?`
|
|
|
|
|
|
|
|
|
|
- Print a random number between 0 and 32767:
|
|
|
|
|
|
|
|
|
|
`echo $RANDOM`
|
|
|
|
|
|
|
|
|
|
- Print one of the prompt strings:
|
|
|
|
|
|
|
|
|
|
`echo ${{PS0|PS1|PS2|PS3|PS4}}`
|
|
|
|
|
|
|
|
|
|
- Expand with the output of `command` and run it. Same as enclosing `command` in backtics:
|
|
|
|
|
|
|
|
|
|
`$({{command}})`
|
|
|
|
|
|
|
|
|
|
- List how many arguments the current context has:
|
|
|
|
|
|
|
|
|
|
`echo $#`
|
|
|
|
|
|
|
|
|
|
- Print out a Bash array:
|
|
|
|
|
|
|
|
|
|
`echo ${array[@]}`
|