error and out redirection

John T Ellis ellis at motcid.UUCP
Fri Sep 21 03:38:53 AEST 1990


In article <2682 at crdos1.crd.ge.COM> davidsen at crdos1.crd.ge.com (bill davidsen) writes:
>
>  The other day I posted an example of redirecting stdout into one file,
>stderr into another, and printing the error messages as they happened. I
>reversed the names of the files.
>
>  Several people have told me they can't make this work, so here's my
>demo script of how to do it. It runs on SunOS, Ultrix, Stelix, Convex,
>Xenix, and V5.3.2.
Stuff deleted
-- 
>bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
>    VMS is a text-only adventure game. If you win you can use unix.

For CSH users, you can do the following:

% (command > std.out) &> std.err

Why this works is that you FIRST execute () with the standard output going
to std.out, BUT any errors generated by () will be MERGED with standard
output to std.err.  Since you already sent standard output somewhere else,
the merge results in only the errors!  Pretty slick eh?!

Later.

-- 
---------------------------------------------------+----------------------------
Any sufficiently advanced technology               | John T. Ellis  708-632-7857
   is indistinguishable from magic.  :-}           |     Motorola Cellular
                                                   |   ...uunet!motcid!ellis



More information about the Comp.unix.shell mailing list