Unix나 Linux의 Console에서 작업을 할 때, 작업 결과로 나오는 텍스트 내용을 저장하기 위해 ">"를 사용하곤 합니다.
하지만 그럴 경우 콘솔에는 해당 내용이 표시되지 않게 되죠. 예를 들어 폴더내의 파일 리스트를 보는 "ls"를 아래와 같이 사용하면
$ ls > list.txt
$
$
list.txt에 ls의 결과가 저장되게 됩니다.
하지만, 작업이 진행되는 내용을 동시에 보고 싶은 경우도 있지요. 이를 위해 tee 를 사용할 수 있습니다.
$ ls | tee list.txt
a.c
b.c
d.c
$
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.
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.
표시된 것처럼 표준 출력으로 나오는 것을 지정된 파일에 복사해주게 됩니다. 내용은 참 간단하지만, 의외로 유용하게 쓰인답니다.
댓글을 달아 주세요