Content of a file named file
testing 1
testing 2
Command tested
exec 3<> ./tmp
cat file 1>&3 3>&1
Outputs nothing. Why?
I read my command as
cat content in file, then read STDOUT and give it to file descriptor 3 and then take the content from file descriptor 3 and give it's content to STDOUT
Am I reading my command wrong ?
How shall I read my command in order to understand it better and get the output of file
After understanding your answer Stéphane, I tried the following commands
cat file 1>&3 3> ofile
which didn't write the contents of fd 3 (which gets it's content from fd 1 i.e STDOUT) to ofile
but the I tried the following command
cat file 1>&3 && cat <3
which printed the content of fd 3 to the STDOUT.
Why didn't fd 3 write to ofile when fd 3 has the content of fd 1 ?
Stéphane, the command Jesse_b mentioned in the comments below i.e
cat file 3> ofile 1>&3
works and does write the content of file to ofile but the command
cat file 1>&3 3> ofile
as I mentioned earlier fails to write to ofile.
How did the placement of 1>&3 at the end and at the beginning of 3> ofile affect the output of these two commands ?
filetoSTDOUTyou can execute this command:cat fileIf you want to redirectSTDOUTto something else you can docat file >orcat file 1>1>&3you aren't saying "redirect 1 to 3" you are saying "redirect 1 and 3"cat file 3> ofile 1>&3also I don't think your second command is actually working. I think it's executing:cat fileand throwing away1>&3 && cat <3command > /dev/null 2>&1