Interview Prep/Linux/Packages, Shell & Text Tools

What is command substitution and process substitution?

IntermediateConceptPackages, Shell & Text Tools
Answer

Command substitution $(cmd) inserts the output of a command as text. Process substitution <(cmd) gives a file path (/dev/fd/63) that streams the command's output, useful for tools that want files.

echo "Kernel: $(uname -r)"
diff <(ssh web1 cat /etc/nginx/nginx.conf) <(ssh web2 cat /etc/nginx/nginx.conf)

Prefer $(...) over backticks: it nests cleanly.

All Linux questions Roadmap: Linux

More on Packages, Shell & Text Tools