Here's one more I'm using sometimes:
$ call-foo > out_and_err.txt 2>&1
So here I'm redirecting STDERR to the address of STDOUT, which is a file called "out_and_err.txt".
What's & mean?
I think that in recent bash and zsh, one can use
call-foo &> out_and_err.txt
This is my favourite "shut up, I don't want to see any output, even if it fails, just do, or don't do, the thing" shortcut:
call-foo &> /dev/null
I think you have a small typo here.
Shouldn't it read
Thank you, fixed 😁
I would've done call-foo > out-and-error.txt 2> out-and-error.txt; I've never heard of 2>&1 or &>. Very cool! Thanks for that!
call-foo > out-and-error.txt 2> out-and-error.txt
What would be a practical application of print stdout and stderr to the same file?
Openssl prints diagnostic info to stderr and certificate info to stdout. If you want them both in the same filter stream, &> is very handy. Or if you want them all in the same single log file
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.