News for hackers. Stuff that matters.
Re:What does " 2>&1 " mean? by ontouchstart on Friday February 27, 2026 @09:27AM (#47180844)
Sometime all you need is to RTMF from the source instead of Nth hand information (N > 1)

https://www.gnu.org/software/bash/manual/html_node/Redirecti...

Re:What does " 2>&1 " mean? by GuB-42 on Friday February 27, 2026 @09:46AM (#47181072)
Great if you know where to look, but most people who ask themselves the question don't know they have to look up the bash manual in the "redirection" section.

The usual thing (before LLMs) is to Google the question, but for the question to appear in Google, someone has to ask it first, and here we are.

Also the Stackoverflow answers give different perspectives, context, etc... rather than just telling you what it does, which is useful to someone unfamiliar with how redirections work. As I said, someone who doesn't know about "2>&1" is unlikely to be an expert given how common the pattern is, so a little hand holding doesn't hurt.

Re:What does " 2>&1 " mean? by layer8 on Friday February 27, 2026 @10:49AM (#47181899)
> Great if you know where to look, but most people who ask themselves the question don't know they have to look up the bash manual in the "redirection" section.

Where else would you look but in the manual of your shell? And you don’t have to know in which section to look, you can just search for “2>&1” in the bash man page.

Re:What does " 2>&1 " mean? by GuB-42 on Friday February 27, 2026 @11:49AM (#47182677)
What is a command and what is shell syntax is not always obvious, especially to a beginner, which I assume most people asking this question are.

Take the command "ls -l ~/.. ; fg" for instance. What is interpreted by the shell and what are commands? If you have some experience in bash, you probably know, and therefore you know which part to look in which man page, but you probably also know "2>&1".

Spoiler: "-l" is part of the command, so look in the "ls" manpage. "~", is expanded by the shell, ";" is shell syntax and "fg" is a builtin, all three are in the "bash" manpage. ".." is part of the filesystem.

Re:What does " 2>&1 " mean? by shevy-java on Friday February 27, 2026 @09:59AM (#47181266)
And how do you find that?

Google search literally is useless for these days, for Average Joe.

Re:What does " 2>&1 " mean? by momentoftop on Friday February 27, 2026 @10:32AM (#47181696)
Try "info bash" on your system. It's the same manual.

In Emacs, when I hit C-h i I get a menu of all my info manuals and I first read the bash one there.

Re:What does " 2>&1 " mean? by ontouchstart on Friday February 27, 2026 @10:35AM (#47181738)
That is correct. And also simple `man bash`:

REDIRECTION Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell. Redirection may also be used to open and close files for the current shell execution environment. The following redirection operators may precede or appear anywhere within a simple command or may follow a command. Redirections are processed in the order they appear, from left to right.

       In the following descriptions, if the file descriptor number is
       omitted, and the first character of the redirection operator is <, the
       redirection refers to the standard input (file descriptor 0).  If the
       first character of the redirection operator is >, the redirection
       refers to the standard output (file descriptor 1).

       The word following the redirection operator in the following
       descriptions, unless otherwise noted, is subjected to brace expansion,
       tilde expansion, parameter expansion, command substitution, arithmetic
       expansion, quote removal, pathname expansion, and word splitting.  If
       it expands to more than one word, bash reports an error.

       Note that the order of redirections is significant.  For example, the
       command

              ls > dirlist 2>&1

       directs both standard output and standard error to the file dirlist,
       while the command

              ls 2>&1 > dirlist

       directs only the standard output to file dirlist, because the standard
       error was duplicated as standard output before the standard output was
       redirected to dirlist.
...
Re:What does " 2>&1 " mean? by momentoftop on Friday February 27, 2026 @10:43AM (#47181825)
Ah, thanks, didn't realise they put the whole manual into the manpage. For other tools (e.g. make), the info manual is complete but the manpage is just a summary.
Re:What does " 2>&1 " mean? by giglamesh on Friday February 27, 2026 @10:04AM (#47181331)
Do these days include the nearly seventeen years ago when this question was posted? ;)
Re:What does " 2>&1 " mean? by ontouchstart on Friday February 27, 2026 @10:21AM (#47181567)
https://www.gnu.org was there for decades, much older than SO and google.

I know GNU -> Google -> SO -> LLM is a culture shift, this is how human attention goes. The search engine and LLM only capture the latest group attention and we have short memory. That is why reading is a critical skill for us as human beings, we can't afford to outsource that to machine. (Same with writing.)