Search code examples
linuxgitbashbackticks

How can I suppress command output when using backticks?


Is there a way to supress the command output for git if I use backticks in my shell script? Here is my current code:

OUT=$(git status > /dev/null)

Thanks :)


Solution

  • I think what you're wanting is to suppress the stderr but not the stdout since you still want the value. You could do this instead:

    OUT=$(git status 2>/dev/null)