How do I write to a file and print to a terminal cuncurrently in Unix?

Posted by bias on Stack Overflow See other posts from Stack Overflow or by bias
Published on 2010-05-26T22:48:43Z Indexed on 2010/05/26 23:01 UTC
Read the original article Hit count: 324

I have a little bash function to log my Macports outputs to a file (since installs often spew little tidbits that are easy to lose in terminal noise), then I just cat the file to the terminal:

function porti {
    command sudo port install $@ >> $1.log 2>&1; cat $1.log
}

Is there a way to do this concurrently?

I don't care about it being in Bash, that's just how I started it.

BTW I pass $@ to install but only $1 for the file name so that I can do something like:

porti git-gore +bash_completion

and only get the file git-core.log however someone else might prefer to include variants in the file name ...

© Stack Overflow or respective owner

Related posts about bash

Related posts about file-io