What is process substitution and when do you use it?
IntermediateConceptArguments, I/O, here-docs, process substitution and subshells
Answer
<(cmd) runs cmd and substitutes a path (like /dev/fd/63) from which its output can be read; >(cmd) gives a path that feeds cmd's stdin.
diff <(ssh web1 cat /etc/nginx/nginx.conf) <(ssh web2 cat /etc/nginx/nginx.conf)
comm -13 <(sort expected_users.txt) <(cut -d: -f1 /etc/passwd | sort)
while read -r pod; do ...; done < <(kubectl get pods -o name) # loop in current shell
exec > >(tee -a "$log") 2>&1 # log everything
It is Bash/zsh only. Under sh (dash) you get Syntax error: "(" unexpected.
More on Arguments, I/O, here-docs, process substitution and subshells
How does `getopts` work? Show a complete example.IntermediateWhat is the difference between `getopts` and `getopt`?AdvancedExplain file descriptors 0, 1 and 2 and the main redirection operators.BeginnerWhy is `cmd 2>&1 > file` different from `cmd > file 2>&1`?AdvancedWhat is a here-document, and what is the difference between `<<EOF`, `<<'EOF'` and `<<-EOF`?BeginnerWhat is a here-string (`<<<`)?Intermediate