Reputation: 43
As an example not that it would work but say
mkdir -p ${ZDIR}${BIND_DIR} 2>&1 | tee -a $ZLOG || exit 1
The above isn't going to work as stdout/stderr is already redirected but always get confused here with how and the format of redirection. Is there a oneliner or if/fi where stdout/stderr can be redirected to a log file whilst if not successful can end with a exit or return 1?
Doesn't have to have the tee to screen can just be straight redirect to file. I always struggle with the bash format and struggling for an example with redirection and interaction.
Upvotes: 0
Views: 51
Reputation: 50750
mkdir -p "${ZDIR}${BIND_DIR}" 2>"$ZLOG" || exit 1
2>"$ZLOG"
: stderr is redirected to $ZLOG
.
|| exit 1
: if the command exits with a non-zero value, exit with 1
.
Upvotes: 1