I'm using the following to to tee output of a command into a file:
logs/`basename $0`-`basename $1`.`date +%F--%R\`.log
And since this same syntax belongs in several different shell scripts, I'd really like it to only appear once. My first thought was to put it in another shell script:
export LOGFILE=logs/`basename $0`-`basename $1`.`date +%F--%R`.log
# OR
export LOGFILE=logs/\`basename $0\`-\`basename $1\`.\`date +%F--%R\`.log
And have each file call the command like this:
java CMD | tee $LOGFILE
However this doesn't work. Is there any way to describe a file to create in the way you see above only once but be able to reference it repeatedly in scripts?