1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-24 22:55:31 +02:00
tldr/pages/common/readonly.md
Alejandro Cervera ced5cb22f6
common/*: update pages of POSIX special Built-In utilities (#11858)
* eval, exec, exit, export, readonly, set, shift, trap: use Open Group links

* exec, export, trap: split Linux and POSIX
2023-12-29 18:37:58 +05:30

17 lines
593 B
Markdown

# readonly
> Create or modify read-only variables within a shell script, preventing the variable from being changed by subsequent commands.
> This is useful when you want to ensure that a variable retains a constant value throughout the execution of a script.
> More information: <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#readonly>.
- Create a read-only variable:
`readonly {{variable_name}}={{value}}`
- Mark a variable as read-only:
`readonly {{existing_variable}}`
- [p]rint the names and values of all read-only variables to `stdout`:
`readonly -p`