알아두면 유용한 명령어 : script, tee

|

script에 대해서는, 주로 애용하는 CentOS 3.4 의 man page에 요렇게 적혀 있다.

Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).


그러니까 터미널을 통해서 표시되는 모든 것의 typescript를 만들어주는 명령이다. 학생들에게 유용하며 머 주저리주저리 적어놓았는데, 뭔가 테스트 하면서 기록을 남기거나, pipe redirection을 사용하기 힘들때 매우 유용하게 사용한 경험이 있다.


단점은 터미널에 표시되는 글씨 색의 code들과, new line이 CR+LF(즉, ^M)로 표시된다는 것이다.

tee는 주로 pipe로 사용하는 명령어이다. 역시 man page에서 확인해보자.

Copy standard input to each FILE, and also to standard output.

그러니까 standard input으로 들어오는 내용을 읽어서 지정된 파일에 저장하고, 그 내용을 또한 standard output으로 표시한다는 의미이다.

이 명령은 테스트를 확인하면서 동시에 로그를 남길때 유용하게 사용했다. 이를테면,

elenoa# iostat 1 | tee iostat.save


이런식으로.


And