0

I want to put all errors inside a file and prevent errors and success messages from printing on the screen. I only want to store the error message.

When I do this like the code below, the errors and success messages are shown on the screen and also inside the error.out file.

git ls-remote "$GIT_SSH_URL/$REPO.git" 2>&1 > /dev/null | tee error.out
CodeWhisperer
  • 1,143
  • 2
  • 19
  • 39

2 Answers2

1

Get rid of the 2>&1 > /dev/null | tee error.out part first. 2>&1 combines the errors and the output, which you don't want, and tee prints the input it gets, which you also don't want.

> /dev/null suppresses output, and 2> error.out sends errors to the file.

Dan
  • 12,409
  • 3
  • 50
  • 87
1

Try this:

 git ls-remote "$GIT_SSH_URL/$REPO.git" 2>file.log 1>/dev/null
SLePort
  • 15,211
  • 3
  • 34
  • 44