tee 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-tee
핵심 정리
- 표준 입력을 읽어 표준 출력에 쓰면서 동시에 지정한 파일(여러 개 가능)에도 복사합니다.
- 기본은 파일을 덮어쓰고,
-a는 파일 끝에 덧붙입니다. -i는 인터럽트를 무시합니다.- 한 파일에 쓰기가 실패해도 다른 파일과 표준 출력에는 계속 쓰고, 종료 값만 0보다 크게 돌려줍니다.
- 명령의 출력을 화면으로 보면서 로그로 남길 때 씁니다(
명령 | tee 파일). - AIX 5.3과 6.1 문서의 내용이 같습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (두 버전 내용 같음) |
| 원문 | IBM Commands Reference — 5.3 Volume 5, 6.1 Volume 5 |
| 파일 | /usr/bin/tee |
| 관련 명령어 | script |
목적
프로그램의 출력을 표시하면서 파일에 복사합니다.
영어 원문
Displays the output of a program and copies it into a file.
구문
tee [ -a ] [ -i ] [ File ... ]
설명
tee 명령은 표준 입력을 읽어, 프로그램의 출력을 표준 출력에 쓰면서 동시에 지정한 파일(하나 이상)에 복사합니다.
영어 원문
The tee command reads standard input, then writes the output of a program to standard output and simultaneously copies it into the specified file or files.
플래그
| 플래그 | 설명 |
|---|---|
-a |
File을 덮어쓰지 않고 끝에 출력을 덧붙입니다. |
-i |
인터럽트를 무시합니다. |
영어 원문
-a— Adds the output to the end of File instead of writing over it.-i— Ignores interrupts.
종료 상태
| 값 | 뜻 |
|---|---|
| 0 | 표준 입력을 모든 출력 파일에 잘 복사했습니다. |
| 0보다 큼 | 오류가 났습니다. |
참고: 잘 연 File 피연산자 중 하나에 쓰기가 실패해도, 잘 연 다른 File과 표준 출력에는 계속 쓰며 종료 값만 0보다 크게 됩니다.
영어 원문
This command returns the following exit values:
- 0 — The standard input was successfully copied to all output files.
>0— An error occurred.- Note: If a write to any successfully opened File operand is not successful, writes to other
successfully opened File operands and standard output will continue, but the exit value will be >0.
예제
- 명령의 출력을 보면서 동시에 저장합니다.
lint program.c의 표준 출력을 화면에 보여 주면서program.lint파일에 사본을 저장합니다.program.lint가 이미 있으면 지우고 새로 씁니다.
lint program.c | tee program.lint
- 명령의 출력을 보면서 기존 파일에 덧붙입니다.
lint program.c의 출력을 화면에 보여 주면서program.lint끝에 덧붙입니다.program.lint가 없으면 만듭니다.
lint program.c | tee -a program.lint
영어 원문
- To view and save the output from a command at the same time:
lint program.c | tee program.lint
This displays the standard output of the command lint program.c at the workstation, and at the same time saves a copy of it in the file program.lint. If a file named program.lint already exists, it is deleted and replaced.
- To view and save the output from a command to an existing file:
lint program.c | tee -a program.lint
This displays the standard output of the lint program.c command at the workstation and at the same time appends a copy of it to the end of the program.lint file. If the program.lint file does not exist, it is created.
파일
| 파일 | 설명 |
|---|---|
/usr/bin/tee |
tee 명령이 들어 있습니다. |
관련 명령어: script
영어 원문
- /usr/bin/tee — Contains the tee command.
Related reference:
- script Command
Related information:
- Input and output redirection
리눅스(GNU)와 다른 점
리눅스의 GNU tee도 -a와 -i를 같은 뜻으로 씁니다. AIX 5.3·6.1 문서에는 -p(파이프 오류 처리), --output-error 같은 GNU 옵션이 없습니다.