-1

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.

Here is the image of the script

Jahidul Islam
  • 11,435
  • 3
  • 17
  • 38
cycool29
  • 78
  • 7

2 Answers2

0

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.
Lynch
  • 9,174
  • 2
  • 23
  • 34
0

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