4.6 The T-Junction

   

4.6 The T-Junction

This is a special type of pipe similar to a T pipe junction in real life. This is used to redirect incoming data in a pipe to more than one place. Please see Figure 4-7 to get an idea how the T-junction works.

Figure 4-7. The T-junction.

graphics/04fig07.gif

The tee command is used to form a T-junction. It takes its input from stdin and writes the same thing to stdout as well as to another file at the same time. Consider the same example of the who command. If you want to display the output of the who command at the terminal as well as save it in whofile for future use, the command line and result will be as follows .

 $  who  tee whofile  operator   pts/ta       Aug 30 16:05 boota      pts/tb       Aug 30 15:59 mike       pts/tc       Aug 30 15:44 linda      pts/td       Aug 30 14:34 $ 

Now if we see the contents of the whofile , it will contain the same data.

 $  cat whofile  operator   pts/ta       Aug 30 16:05 boota      pts/tb       Aug 30 15:59 mike       pts/tc       Aug 30 15:44 linda      pts/td       Aug 30 14:34 $ 

Like ordinary pipes and redirection symbols, multiple levels of t-junction pipe can be used to send data to many places. Can you use the sort or head commands with the tee command now? How about using the spell command to check spellings of a command output?

Table 4-2 is a summary of the redirection and pipe symbols used in HP-UX.

Table 4-2. Standard I/O Redirection
Symbol Function Syntax
> Redirect stdout and overwrite or create a file prog > file
< Redirect stdin prog < file
>> Redirect stdout and append to, or create a file prog >> file
2> Redirect stderr prog2> file
2>&1 Send stderr and stdout to the same file prog2>&1 file
Pipe stdout of prog1 to stdin of prog2 prog1 prog2
& Pipe stdout and stderr of prog1 to stdin of prog2 prog1 & prog2
Note: prog , prog1 , and prog2 represent a command or executable program, while file is any file

   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net