I don't quite understand how the computer reads this command.
cat file1 file2 1> file.txt 2>&1
If I understand, 2>&1
simply redirect Standard Error to Standard Output.
By that logic, the command reads to me as follows:
concatenate files
file1
andfile2
.send
stdout
from this operation tofile.txt
.send
stderr
tostdout
.end?
I'm not sure what the computer's doing. By my logic, the command should be
cat file1 file2 2>&1 > file.txt
but this is not correct.
$
stand for? – Eliran Malka Jun 24 '19 at 14:28var=$othervar
,$
introduces the variable name on the right hand side. In a redirection like2>&1
,&
introduces the file descriptor number on the right hand side. I'm saying you can think of it like "file 2 equals file 1". (But there are two types of equals:<
means "for reading" and>
means "for writing".) – Mikel Jun 25 '19 at 15:481
or2
you understand the difference between2>1
and2>&1
per @Mikel Also, I appreciate the mental translation, it works for me.1>&2
becomes1 = $2
which syntactically "sort of" means something in bash, RegEx, and probably Perl. – razzed Sep 16 '20 at 16:39