0

How do I accomplish this command to redirect command output to multiple files, without retyping the later A=1>&/dev/tty 1>&${TMP}/lastcmdout every time?

I want to see output on the current TTY and redirect to files. The following accomplishes what I want, but I don't want to retype the ending.

$ cmd0 | cmd1 1>&/dev/tty 1>&${TMP}/lastcmdout

I tried making a script shttf:

${SHELL} -c ${1} 1>&/dev/tty 1>&${TMP}/lastcmdout

and invoking

$ shttf 'cmd1 | cmd2'

so I can see the output and also redirect it a file, however this isn't working.

I'm considering these shells: ksh88, ksh93, zsh.

2
  • I know nothing about ksh and little about zsh so this is just an idea that may work (with a different syntax) in one of these shells. In bash you can permanently change file descriptors with exec 1>&/dev/tty Commented Jan 25 at 20:49
  • 1
    Are you looking for the tee command that seems to do what you want; cmd | tee /tmp/output will send the output of cmd to the screen and to the file. Commented Jan 26 at 0:33

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.