Is there a way to interact with file descriptors without having to open a file on disk?
This won't work without a file first being assigned to fd3:
echo a >&3
Depends on what you want to do. Suppose you want to write strings at your leisure and print them reversed. set up a file descriptor redirecting into a process substitution waiting for stdin:
$ exec 3> >(rev)
$ echo hello world >&3
dlrow olleh
When you're done with it, you can close the file descriptor
$ exec 3>&-
$ echo hello world >&3
bash: 3: Bad file descriptor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With