"리눅스 tee, 화면과 파일에 동시 출력하기"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-<source +<syntaxhighlight , -</source> +</syntaxhighlight>))
 
(사용자 3명의 중간 판 5개는 보이지 않습니다)
1번째 줄: 1번째 줄:
{{다른뜻|티 ⊤}}
==개요==
==개요==
;리눅스 화면과 파일에 동시에 출력하기
;리눅스 화면과 파일에 동시에 출력하기
5번째 줄: 6번째 줄:
*[[표준출력]](stdout)을 화면과 파일로 동시에 출력하는 리눅스 명령어
*[[표준출력]](stdout)을 화면과 파일로 동시에 출력하는 리눅스 명령어


https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Tee.svg/400px-Tee.svg.png
[[파일:Tee.svg|400px]]


==기본==
* 표준출력을 화면출력·파일기록<ref>명령어의 표준출력이 tee에 표준입력으로 전달됨</ref>
* 표준출력을 화면출력·파일기록<ref>명령어의 표준출력이 tee에 표준입력으로 전달됨</ref>
<source lang='bash'>
<syntaxhighlight lang='bash'>
명령어 | tee 파일명
명령어 | tee 파일명
</source>
</syntaxhighlight>
* 표준출력을 화면출력·파일기록 (단, 기존내용 유지하고 내용 추가)
 
<source lang='bash'>
==append==
* 표준출력을 화면출력·파일기록 ( 기존내용 유지하고 내용 추가)
<syntaxhighlight lang='bash'>
명령어 | tee -a 파일명
명령어 | tee -a 파일명
</source>
</syntaxhighlight>
* 출력+오류를 화면출력·파일기록 (오류메시지 포함하여 파일로 저장)<ref>2>&1 가 붙어 있기 때문에 명령어의 표준오류도 표준출력으로 전환되고 그것이 tee로 전달된다.</ref>
 
<source lang='bash'>
==표준출력+표준오류==
* 표준출력과 표준오류를 화면출력·파일기록 (오류메시지 포함하여 파일로 저장)
* 2>&1 가 붙어 있기 때문에 명령어의 표준오류도 표준출력으로 전환되고 그것이 tee로 전달된다.
<syntaxhighlight lang='bash'>
명령어 2>&1 | tee 파일명
명령어 2>&1 | tee 파일명
</source>
</syntaxhighlight>


==실습==
==실습==
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# df -h | tee df.txt
[root@zetawiki ~]# df -h | tee df.txt
Filesystem            Size  Used Avail Use% Mounted on
Filesystem            Size  Used Avail Use% Mounted on
28번째 줄: 35번째 줄:
/dev/vda1              99M  27M  68M  28% /boot
/dev/vda1              99M  27M  68M  28% /boot
tmpfs                1006M    0 1006M  0% /dev/shm
tmpfs                1006M    0 1006M  0% /dev/shm
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# cat df.txt
[root@zetawiki ~]# cat df.txt
Filesystem            Size  Used Avail Use% Mounted on
Filesystem            Size  Used Avail Use% Mounted on
36번째 줄: 43번째 줄:
/dev/vda1              99M  27M  68M  28% /boot
/dev/vda1              99M  27M  68M  28% /boot
tmpfs                1006M    0 1006M  0% /dev/shm
tmpfs                1006M    0 1006M  0% /dev/shm
</source>
</syntaxhighlight>
:→ 화면에 출력된 것과 동일하게 df.txt에도 저장되어 있다.
:→ 화면에 출력된 것과 동일하게 df.txt에도 저장되어 있다.


42번째 줄: 49번째 줄:
*[[윈도우 화면과 파일에 동시에 출력하기]]
*[[윈도우 화면과 파일에 동시에 출력하기]]
*[[표준스트림]]
*[[표준스트림]]
*[[리눅스 tail]]


==주석==
==참고==
<references/>
 
==참고 자료==
*http://www.skorks.com/2009/09/using-bash-to-output-to-screen-and-file-at-the-same-time/
*http://www.skorks.com/2009/09/using-bash-to-output-to-screen-and-file-at-the-same-time/


[[분류:리눅스]]
[[분류:리눅스]]
[[분류: /usr/bin]]
[[분류: /usr/bin]]

2022년 4월 28일 (목) 13:14 기준 최신판

  다른 뜻에 대해서는 티 ⊤ 문서를 참조하십시오.

1 개요[ | ]

리눅스 화면과 파일에 동시에 출력하기
리눅스 tee
/usr/bin/tee
  • 표준출력(stdout)을 화면과 파일로 동시에 출력하는 리눅스 명령어

Tee.svg

2 기본[ | ]

  • 표준출력을 화면출력·파일기록[1]
명령어 | tee 파일명

3 append[ | ]

  • 표준출력을 화면출력·파일기록 ( 기존내용 유지하고 내용 추가)
명령어 | tee -a 파일명

4 표준출력+표준오류[ | ]

  • 표준출력과 표준오류를 화면출력·파일기록 (오류메시지 포함하여 파일로 저장)
  • 2>&1 가 붙어 있기 때문에 명령어의 표준오류도 표준출력으로 전환되고 그것이 tee로 전달된다.
명령어 2>&1 | tee 파일명

5 실습[ | ]

[root@zetawiki ~]# df -h | tee df.txt
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       35G  3.7G   30G  11% /
/dev/vda1              99M   27M   68M  28% /boot
tmpfs                1006M     0 1006M   0% /dev/shm
[root@zetawiki ~]# cat df.txt
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       35G  3.7G   30G  11% /
/dev/vda1              99M   27M   68M  28% /boot
tmpfs                1006M     0 1006M   0% /dev/shm
→ 화면에 출력된 것과 동일하게 df.txt에도 저장되어 있다.

6 같이 보기[ | ]

7 참고[ | ]

  1. 명령어의 표준출력이 tee에 표준입력으로 전달됨
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}