Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!seismo!cmcl2!rna!dan From: dan@rna.UUCP Newsgroups: comp.unix.questions Subject: Stupid shell I/O redirection question... Message-ID: <612@rna.UUCP> Date: Mon, 23-Feb-87 00:12:01 EST Article-I.D.: rna.612 Posted: Mon Feb 23 00:12:01 1987 Date-Received: Tue, 24-Feb-87 02:29:23 EST Organization: Rockefeller Neurobiology Lines: 26 Forgive me for being lazy and not finding the (one true) answer myself, but I've always wanted to know how to do the following: I have a shell script which issues commands that generate output on both the stdout and stderr (1 and 2). I want to redirect both stdout and stderr of the script through a pipe (without hacking the script (the same question would apply to a single program that wrote on 1 and 2, anyways). Like this: cmd: time date time who The time command writes its answer to stderr while date and who write to stdout. I then wish to redirect both outputs to a pipe, say tee to both see and capture the results (I know I could use script, etc.) The best solution I could find is: (cmd 2>&1) | tee log I believe this wastes a shell, but just removing the () doesn't work since the 2>&1 (dup syscall) happens before the pipe is created. Perhaps (exec cmd 2>&1) | tee log Well is there some other syntax or funny combination of >|12& to use ?