I have my script like this:
git clone https://github.com/ITdairy/whatsapp-for-linux 2>&1 > log.txt
But the git
still show the output in the terminal, and cat log.txt
shows nothing.
I have my script like this:
git clone https://github.com/ITdairy/whatsapp-for-linux 2>&1 > log.txt
But the git
still show the output in the terminal, and cat log.txt
shows nothing.
Swap the redirection. First you send stdout to a file the redirect stderr to stdout.
grep > /tmp/log 2>&1; sleep 2; cat /tmp/log
output this after 2 seconds:
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
I have tried this way and it worked for me:
git clone --progress https://github.com/ITdairy/whatsapp-for-linux &>log.txt
Source: https://askubuntu.com/questions/989015/how-to-get-git-producing-output-to-a-file