- What is the outcome when we run the following commands?
$ exec 5>/tmp/xyz
$ echo hello >&5
$ exec 5>/tmp/xyz : This line will open the file with location "/tmp/xyz" having filename as "xyz" using file descriptor 5. In other words the integer 5 is used as an indicator to access the file xyz. It can be also said that this comman will open the file xyz with FD 5.
$ echo hello >&5 : The command echo is basically used to output some string. Here, the string hello is printed along with >&5. This indicates that inside the file pointed by FD 5, the corresponding string will be written. In other words, hello will be written to the file pointed by FD 5.
CONCLUSION: Both the commands together will open the file located at "/tmp/" having a name "xyz" (using file descriptor 5, FD 5) and write (or print) "hello" in the file.
Get Answers For Free
Most questions answered within 1 hours.