BSD Newsletter.com
   Front | Info | Lists | Newsfeeds | Study Guide | What is BSD?
Advertisement: The OpenBSD PF Packet Filter Book: PF for NetBSD, FreeBSD, DragonFly and OpenBSD

BSD Links
·New Links
·Advocacy
·Drivers
·Events
·Flavours
·FAQs
·Guides
·Programming
·Security
·Software
·User Groups

This is the BSDA Study Guide Book written via a wiki collaboration. This is a work in progress. You may contribute to or discuss this specific page at http://bsdwiki.reedmedia.net/wiki/Demonstrate_proficiency_in_using_redirection__44___pipes_and_tees.html.

Demonstrate proficiency in using redirection, pipes and tees

Concept

Be able to to redirect standard input, output or error, use a pipe to send the output of one command to another command or file, and use a tee to copy standard input to standard output.

Introduction

tee: pipe fitting, this utility copies standard input to standard output, making a copy in zero or more files. The output is unbuffered.

file descriptors (fd):

fd 0: stdin

fd 1: stdout

fd 2: stderr

<: redirect stdin of a process so that input is read from a file instead of from the keyboard

command < infile

>: redirects stdout to a file

command > outfile

>>: appends stdout to a file

command >> outfile

| : piping command output to another command

command1 | command2 | ... | commandN

tee: lets you divert a copy of the data passing between commands to a file without changing how the pipeline functions

who | tee savewho | wc -l

>&: temporarily connect something to something else

ls 2>&1 means temporarily connect stderr to stdout

|&:

Examples

Practice Exercises

More information

<, >, |, tee(1), >\& and |\&



Front | Information | Lists | Newsfeeds