logoalt Hacker News

vessenesyesterday at 10:30 PM3 repliesview on HN

Not sure why this link and/or question is here, except to say LLMs like this incantation.

It redirects STDERR (2) to where STDOUT is piped already (&1). Good for dealing with random CLI tools if you're not a human.


Replies

WhyNotHugoyesterday at 11:08 PM

Humans used this combination extensively for decades too. I'm no aware of any other simple way to grep both stdout and stderr from a process. (grep, or save to file, or pipe in any other way).

show 1 reply
ElijahLynnyesterday at 10:39 PM

I found the explanation useful, about "why" it is that way. I didn't realize the & before the 1 means to tell it is the filedescriptor 1 and not a file named 1.

show 2 replies
anitilyesterday at 11:21 PM

I've also found llms seem to love it when calling out to tools, I suppose for them having stderr interspersed messaged in their input doesn't make much difference