I tried to use the read/write file descriptor in bash so that I could delete the file that the file descriptor referred to afterward, as such:
F=$(mktemp) ex
#!/bin/bash F=$(mktemp tmp.XXXXXX) exec 3<> $F rm $F echo "Hello world" >&3 cat /dev/fd/3
As suggested in other answer, cat will rewind the file descriptor for you before reading from it since it thinks it's just a regular file.
cat