/home/wpollock1/public_html/restricted/ShellScripting/pipe-stderr.sh

#!/bin/bash
# Demo shell script showing how to pipe stderr of some command,
# while not redirecting stdout.  (Had I been consulted Unix would
# support "cmd 2| cmd".  But they didn't, so we are stuck using
# the following.)
#
# Written 5/2007 by Wayne Pollock, Tampa Florida USA.
# $Id: pipe-stderr.sh,v 1.0 2007/05/07 17:23:09 wpollock Exp $

LC_COLLATE=POSIX  # So tr ranges work

# Step one: copy stdout for later:
exec 3>&1

# genoutput is a short C program that produces one line of
# text to stdout and another to stderr:

#        #include <stdio.h>
#        int main (void)
#        { printf( "this was sent to stdout\n" );
#          fprintf( stderr, "THIS WAS SENT TO STDERR\n" );
#          return 0;
#        }

# (Make sure it is on your PATH, or use a pathname below:
# If all goes well only the uppercase letters (stderr) should be
# scrambled by tr:

genoutput 2>&1 1>&3 | tr a-zA-Z b-zaB-ZA

# close duplicate file descriptor:
exec 3>&-