I've been running a lot of similar commands lately, e.g.
python foo.py some args 2>&1 | tee foo.log
python b开发者_JAVA技巧ar.py otherarg 2>&1 | tee bar.log
To save typing, I'd like a shorthand for 2>&1 | tee
like
python foo.py some args $tee foo.log
but when I say export tee='2>&1 | tee'
, this gives me this error: Variable assignment '2>&1' invalid (no "=")
Is there a way to create a convenient shorthand (not necessarily identical to what I've written above) for this kind of output redirection?
why not create a shell script file named XXX with:
python $1.py $* 2>&1 | tee $1.log
or something like that ... (may need "$*" if args have spaces, probably want to check that there is at least 1 arg, etc)
then you would have to type: XXX foo some args XXX bar otherargs
精彩评论