REDIRFD(1)
π REDIRFD(1) β the redirfd girlies' guide π
okay so bestie, we're doing the redirfd page from the General Commands Manual section, and honestly? it's giving backstage-pass-for-your-file-descriptors. let's get into it π
β¨ NAME β¨
redirfd β redirect a given file descriptor to a file, then execute a program. that's the whole personality. that's the job. slay.
πΈ SYNOPSIS πΈ
redirfd [-r | -w | -u | -a | -x] [-n] [-b] fd file prog...
redirfd [-r | -w | -u | -a | -x] [-n] [-b] [-f] [-e | -E] var file
prog...
two whole flavors, both iconic, pick your fighter π«Ά
π DESCRIPTION π
so redirfd takes the file descriptor number fd, redirects it to file, and then exec(3)s into prog.... like it literally becomes your program. main character energy, no going back.
when you run it with the -v option, the first argument gets interpreted as an environment variable instead. yes, the page says -v and we are simply not asking questions π anyway β redirfd opens file, stores the obtained file descriptor into environment variable var, then execs into prog.... cute, right?
and here's the receipts, because i know you love a shell-equivalence moment:
redirfd -r n file prog...is roughly equivalent tosh -c 'exec prog... n<file'redirfd -w n file prog...is roughly equivalent tosh -c 'exec prog... n>file'redirfd -u n file prog...is roughly equivalent tosh -c 'exec prog... n<>file'redirfd -a n file prog...is roughly equivalent tosh -c 'exec prog... n>>file'redirfd -x n file prog...has no portable shell equivalent. not me being built different ππ₯
π¦ Special fifo handling π¦
the -n and -b options are especially useful with named pipes. like, this is their moment. their era. their arc.
- opening a fifo for reading, blocking if there is no writer:
redirfd -r n fifo prog...
- opening a fifo for reading, with instant success even if there is no writer, and blocking at the first attempt to read from it:
redirfd -r -nb n fifo prog...
- opening a fifo for writing, blocking if there is no reader:
redirfd -w n fifo prog...
- opening a fifo for writing, with instant success even if there is no reader:
redirfd -w -nb n fifo prog...
β οΈ warning bestie, for real for real: the first attempt to write to the fifo will raise aSIGPIPEif there is still no reader at that time. the named pipe semantics normally do not allow a fifo to be open for writing without a reading end, and you should know what you are doing if you're usingredirfdthis way. not a vibe check you wanna fail π
π OPTIONS π
one and only one of the -r, -w, -u -a, or -x options must be given; the -n and -b options may be added in any case. choose wisely, bestie π
-rβ open file for reading. just read. that's it. that's the whole thing.-wβ open file for writing, truncating it if it already exists. bye bye old contents π-uβ open file for reading and writing. both?? both. multi-talented king.-aβ open file for appending, creating it if it doesn't exist. adding to the conversation, not interrupting it β¨-xβ open file for writing, creating it, failing if it already exists. exclusive. doesn't do seconds. periodt.-nβ open file in non-blocking mode. no waiting around, we're busy π-bβ change mode of file after opening it: to non-blocking mode if the-noption was not given, to blocking mode if it was. yes it's the flip-flop option. iconic behaviour honestly.-fβ interpret the first argument as an environment variable, and stores the new file descriptor into that variable before execing. putting the fd in the env, lowkey genius.-eβ no autoimport. this is the default. the "we do nothing extra" icon.-Eβ autoimport. this is only useful with the-foption. instead of executingprog..., executeimportas -uSi var prog.... this substitutes var into the command line instead of putting it into the environment. fancy π
π SEE ALSO π
emptyenv(1), envfile(1), exec(1), execline-cd(1), execline-umask(1), exit(1), export(1), fdblock(1), fdclose(1), fdmove(1), fdreserve(1), fdswap(1), getcwd(1), getpid(1), heredoc(1), piperw(1), posix-cd(1), posix-umask(1), trap(1), tryexec(1), unexport(1), wait(1), withstdinas(1), exec(3)
this man page is ported from the authoritative documentation at: https://skarnet.org/software/execline/redirfd.html β go read the source bestie, it's giving scholar energy π
π AUTHORS π
Laurent Bercot Alexis <flexibeast@gmail.com> (man page port)
okay that's the whole page, you're officially an expert, go redirect something responsibly π§ββοΈ and hey β this one's filed under Debian, dated May 5, 2026, so go forth and slay πβπ
π¦ where this page comes from
- nixpkgs unstable: execline 2.9.9.2
- nixpkgs unstable: execline-man-pages 2.9.9.1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms