Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'if you also want to see the output as it happens...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
if you also want to see the output as it happens...
Authored by: soob on Jul 25, '02 10:56:35AM
use:
 |& tee filename
This both displays the output normally to stdout (usually your screen) and redirects a copy to the file you've given. For example, I like to keep logs of all my configures and makes for the various unix utilities and tools I install. So I'll use commands like
./configure |& tee ~/Documents/logs/zsh-4.0.4-configure.log
and
sudo make install |& tee ~/Documents/logs/zsh-4.0.4-install.log
for each of the steps used to configure, make and install the package. I'm able to see the output directly in my terminal screen and automatically get the output saved in my logs directory. There's probably ways to incorporate this into aliases or functions... I know zsh supports global aliases that can be used anywhere in the command, for example. Jim

[ Reply to This | # ]
another cool solution
Authored by: SOX on Jul 25, '02 03:02:46PM

here is a solution that allows you to direct the output to another terminal window or wherever.

open a terminal window and type:
mkfifo /tmp/junk ; perl -we 'while (1) { die unless open FILE ,"/tmp/junk"; \
print $x while ( $x=<FILE>); warn "---end of file--\n" }'

you only need to do that part one time.
then from any other terminal just redirect the output to /tmp/junk

for example:
ls -l >/tmp/junk

will send the output to the other terminal window.
for a cool example try
cat >/tmp/junk

and as you type lines they appear in the other window.

you can of course do whatever you want with the text in the other window. send it to a file or parse it or whatever by adding the approriate redirects in the original command.



[ Reply to This | # ]
if you also want to see the output as it happens...
Authored by: rusto on Jul 25, '02 07:19:17PM

This only worked for me (in the bash shell) if I omitted the "&". Cool hint, thanks!



[ Reply to This | # ]