I have a 'simple' script which runs a few commands, I normally just want to see a few echo's letting me know where it is up to. But occasionally I need a verbose output which shows me the output of some of the commands being executed.
Example for normal use
echo "Simple message"
wget 'http://example.com' > /dev/null
Verbose option
echo "Simple message"
wget 'http://example.com'
I thought of using a variable to store the output redirection
output=""
if [ -z "$1" ]
then
output="> /dev/null"
fi
echo "Simple message"
wget 'http://example.com' $output
Problem is it didn't seem to be working, so I added -x to the shebang and the output shows me
wget 'http://example.com' '>' /dev/null
How can I stop the >
from being single quoted?
There's more going on in the original script than a simple wget, this is just a short example.