01 readonly란
1. 정의
- Shell 변수 (shell variable)를 설정할 때 설정된 값을 변경 불가능하게 하는 명령어 (Mark shell variables as unchangeable)
- 즉, VAR=value 라고만 명시하면 VAR 값을 나중에 변경/삭제 가능하지만 readonly VAR=value 라고 명시하면 추후에 VAR 값 변경/삭제 불가능
- Shell 변수란
- 참조: 2024.04.30 - [Shell] - Shell 변수 (variable)
- Shell Script에서 어떤 데이터 종류(숫자, 문자, 파일명 등등)를 갖고 있던지 궁극적으로는 문자열 형태로 할당되는 변수
2. 문법
readonly [-aAf] [name[=value] ...]
readonly -p
3. 옵션
- An argument of '--' disables further option processing
옵션 | 설명 |
-a | refer to indexed array variables |
-A | refer to associative array variables |
-f | refer to shell functions |
-p | display a list of all readonly variables or functions, depending on whether or not the -f option is given |
4. Exit Status
- Returns success unless an invalid option is given or NAME is invalid
참조
- readonly --help
'Shell' 카테고리의 다른 글
Shell Script 함수 만들기 (0) | 2024.04.30 |
---|---|
Shell 변수 (variable) (0) | 2024.04.30 |
Shell, Shell Script, .sh란 (0) | 2024.04.30 |
case문 사용법 (shell script) (0) | 2024.04.30 |
if문 사용법 (shell script) (0) | 2024.04.29 |