I have seen this command
(echo "hello world" >> /var/log/hello.txt") 2>&1
Usually if I wanted to log out errors in case a command failed e.g the echo
command for example, I'd do:
echo "hello world" 2>/var/log/hello-error.log
And if I wanted to log out both stdout and stderror, I'd do:
echo "hello world" &>/var/log/hello-out-and-error.log
And if I didn't care where these logs went, I'd log them to /dev/null for example
echo "hello world" 2>/dev/null
However, recently, I've come accross this notation and not sure what it means:
(echo "hello world" >> /var/log/hello.txt") 2>&1
What does the notation
2>&1
mean?
Are we grabbing stderror
and logging it out to stdout
? Even saying it doesn't seem to make sense