Zhro Zhro - 6 months ago 19
Bash Question

Write to file descriptor 3 without writing to disk?

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