Process Substitution and Named Pipes
Process Substitution and Named Pipes
Process substitution runs commands and exposes their output as a temporary file descriptor path (e.g. /dev/fd/63):
# Diff the output of two commands without temporary files on disk
diff -u <(systemctl list-unit-files --state=enabled) <(ssh remote-node systemctl list-unit-files --state=enabled)
# Named Pipes (FIFOs):
mkfifo /tmp/myfifo
# Process 1 writes: cat /dev/urandom > /tmp/myfifo &
# Process 2 reads: head -c 100 < /tmp/myfifo
rm /tmp/myfifo