Shinnara's Blog
Talking with Shinnara :: NaraTalk.com

'console'에 해당되는 글 1건

  1. 2009/01/09 Console 의 결과를 파일로 저장하기 (tee 사용)

Unix나 Linux의 Console에서 작업을 할 때, 작업 결과로 나오는 텍스트 내용을 저장하기 위해 ">"를 사용하곤 합니다.

하지만 그럴 경우 콘솔에는 해당 내용이 표시되지 않게 되죠. 예를 들어 폴더내의 파일 리스트를 보는 "ls"를 아래와 같이 사용하면

$ ls > list.txt
$


list.txt에 ls의 결과가 저장되게 됩니다.

하지만, 작업이 진행되는 내용을 동시에 보고 싶은 경우도 있지요. 이를 위해 tee 를 사용할 수 있습니다.

$ ls | tee list.txt
a.c
b.c
d.c
$

man 페이지를 보면 이렇게 나와있습니다.

User Commands                                              tee(1)

NAME
     tee - replicate the standard output

SYNOPSIS
  /usr/bin/tee
     /usr/bin/tee [-ai] [file]...

  ksh93
     tee [-ail] [file]...

DESCRIPTION
  /usr/bin/tee
     /usr/bin/tee copies standard input to standard output,  making  a  copy  in zero or more files. tee does not buffer its output. The options determine if  the  specified  files  are overwritten or appended to.

표시된 것처럼 표준 출력으로 나오는 것을 지정된 파일에 복사해주게 됩니다. 내용은 참 간단하지만, 의외로 유용하게 쓰인답니다.





0 Trackback, 0 Comment

TRACKBACK :: http://naratalk.com/trackback/279 관련글 쓰기

댓글을 달아 주세요

1 
다...... (264)
Computer/Programming (106)
Links (14)
책 읽는 즐거움 (7)
끄적임 (66)
즐거운 과학 나라 (7)
일본 (5)
Study (4)