Skip to content

process substitution

disable posix compatibility to use process substitution
set +o posix
output - write stdout to named pipe (FIFO)
command <(command-list)
echo <(command-list)    # /dev/fd/XX
input - read stdin from named pipe (FIFO)
command >(command-list)
examples
# output
sed -f <(var1='test' envsubst '$var1' < sed-script.sed) file
diff <(sort file1) <(sort file2)

# input
tar -cf >(ssh remote-host tar xf -) .    # archive, copy to remote and unarchive in parallel
tee >(wc -l >&2) < file | gzip > file.gz # count lines and compress file in parallel

last updated: Sat Aug 12 14:29:24 2023

Back to top