2024-10-01 20:20:05 +03:00
|
|
|
# Dollar sign
|
|
|
|
|
2024-10-15 13:48:02 +02:00
|
|
|
> Expand a Bash variable.
|
2024-10-01 20:20:05 +03:00
|
|
|
> More information: <https://gnu.org/software/bash/manual/bash.html#Shell-Variables>.
|
|
|
|
|
|
|
|
- Print a variable:
|
|
|
|
|
|
|
|
`echo ${{VARIABLE}}`
|
|
|
|
|
|
|
|
- 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:
|
|
|
|
|
2024-12-19 19:55:36 +02:00
|
|
|
`echo ${{PS0|PS1|PS2|PS3|PS4}}`
|
2024-10-01 20:20:05 +03:00
|
|
|
|
|
|
|
- Expand with the output of `command` and run it. Same as enclosing `command` in backtics:
|
|
|
|
|
|
|
|
`$({{command}})`
|