29 8 月 2012

Filter Utility – tee

Linux tee filter utilities introduction

Divert STDIN to STDOUT and a target file simultaneously – tee

Here we will introduce two utilities: xargs and tee
The utility tee is used to get most of its data from standard input then write to the standard output and to a file simultaneously. In other words, we can use tee to output mass data containing ten thousand lines, for example, in one target file then use other utilities to find out required contents.

[geego@testbed ~]$ cat tee_test
cat: tee_test: No such file or directory
[geego@testbed ~]$ cat /etc/services | tee tee_test | head -5
# /etc/services:
# $Id: services,v 1.40 2004/09/23 05:45:18 notting Exp $
#
# Network services, Internet style
#
[geego@testbed ~]$ head tee_test
# /etc/services:
# $Id: services,v 1.40 2004/09/23 05:45:18 notting Exp $
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn’t support UDP operations.
# Updated from RFC 1700, “Assigned Numbers” (October 1994). Not all ports
# are included, only the more common ones.
[geego@testbed ~]$