I recently discovered unexpected behavior in a bash script, and I would like to understand this before I get around it. Here's a simplified example:
#! /bin/sh
SCRIPT="/tmp/echoscript.sh >> /tmp/log"
/bin/sh ${SCRIPT}
echoscript.sh just executes 'echo "abc"'
Unexpectedly, 'abc' is sent to the terminal, and not to the / tmp / log file. Why is this?
If I changed the third line to:
/bin/sh ${SCRIPT} >> /tmp/log
Then I get the expected result; 'abc' goes to the log file.
source
share