Skip to content

Instantly share code, notes, and snippets.

@DCx7C5
Created October 14, 2023 23:47
Show Gist options
  • Save DCx7C5/ba9b8f1b77cf410bdf4cb7954d5c1142 to your computer and use it in GitHub Desktop.
Save DCx7C5/ba9b8f1b77cf410bdf4cb7954d5c1142 to your computer and use it in GitHub Desktop.
Create duplicate
$ exec 4<&3   # creates duplicate from 3 to 4
Open file for write/read and assign fd
$ exec 3<> file 
Close fd
$ exec 3>&-    # closes fd 3
Use subshells
$ (exec 3<> file; echo "This is a subshell"; echo "with own file descriptor" >&3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment