Question

I'm trying to pipe the output of a "git pull" command to both a file and stdout using the following script:

STD_OUT=`mktemp`
git pull | $STD_OUT
rm -f $STD_OUT

This results in:

./test.sh: line 2: /tmp/tmp.BITQRbsMSI: Permission denied
error: git-pull died of signal 13

Why am I denied permission to the temp file I just created and what's the alternative?

Was it helpful?

Solution

"Piping to a file" is not a legal operation in bash (or any other shell). The thing following a | has to be a command. If you want to redirect the output from the git operation into the file, use the redirect operator >:

git pull > $STD_OUT
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top