Bash/shell script - shell output redirection inside a function
Posted
by Josh
on Stack Overflow
See other posts from Stack Overflow
or by Josh
Published on 2010-06-01T19:47:30Z
Indexed on
2010/06/01
19:53 UTC
Read the original article
Hit count: 785
function grabSourceFile
{
cd /tmp/lmpsource
wget $1 > $LOG
baseName=$(basename $1)
tar -xvf $baseName > $LOG
cd $baseName
}
When I call this function The captured output is not going to the log file. The output redirection works fine until I call the function. The $LOG variable is set at the top of the file. I tried echoing statements and they would not print. I am guessing the function captures the output itself? If so how do push the output to the file instead of the console. (The wget above prints to console, while an echo inside the function does nothing.)
© Stack Overflow or respective owner