Demonstrate proficiency in using redirection, pipes and tees

Author: name contact BSD flavour

Reviewer: name contact BSD flavour

Reviewer: name contact BSD flavour


Concept

Be able to to redirect standard input(((standard input))), output(((standard output))) or error(((standard error))), use a pipe(((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 |\&