This is meant to be a stupid-short introductory and reference guide for quickly understanding these Bash operators: >, 1>, >>, 1>>...
For further actions, you may consider blocking this person and/or reporting abuse
Here's one more I'm using sometimes:
So here I'm redirecting STDERR to the address of STDOUT, which is a file called "out_and_err.txt".
I think that in recent bash and zsh, one can use
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:
I think you have a small typo here.
Shouldn't it read
Thank you, fixed 😁
You're welcome.
I would've done
call-foo > out-and-error.txt 2> out-and-error.txt
; I've never heard of2>&1
or&>
. Very cool! Thanks for that!What would be a practical application of print stdout and stderr to the same file?
@fennecdjay
@thorstenhirsch
@sinewalker
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 fileWhat's & mean?
stackoverflow.com/questions/818255...
Another really useful redirection-related BASHism:
<( )
:Useful if, say, you want to check to see if a local file and an S3-hosted file are the same:
Similarly, can be used for things like
diff
ing two streams:Another one people don't seem to use much is
>|
which will overwrite a file even ifnoclobber
is on.Makes truncating a breeze!
|> logfile.log
I never looked these up before, though I use most of them almost everyday 😁
Thanks Pierson!
Haha, I was in the same boat!