diff --git a/README.md b/README.md index 4ecbb24..a0bc43e 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ smart people at [Hashrocket](http://hashrocket.com/). ### zsh - [Clear The Screen](zsh/clear-the-screen.md) +- [Create A File Descriptor with Process Substitution](zsh/create-a-file-descriptor-with-process-substitution.md) - [Killing A Frozen SSH Session](zsh/killing-a-frozen-ssh-session.md) - [Search History](zsh/search-history.md) - [Watch This Run Repeatedly](zsh/watch-this-run-repeatedly.md) diff --git a/zsh/create-a-file-descriptor-with-process-substitution.md b/zsh/create-a-file-descriptor-with-process-substitution.md new file mode 100644 index 0000000..5253c97 --- /dev/null +++ b/zsh/create-a-file-descriptor-with-process-substitution.md @@ -0,0 +1,23 @@ +# Create A File Descriptor with Process Substitution + +Process substitution can be used to create a file descriptor from the +evaluation of a shell command. The syntax for process substitution is +`<(LIST)` where `LIST` is one or more bash commands. + +``` +$ cat <(echo 'hello, world') +hello, world +``` + +This is particularly useful for commands that expect files, such as diff: + +``` +$ diff <(echo 'hello, world') <(echo 'hello, mars') +1c1 +< hello, world +--- +> hello, mars +``` + +Sources: [Brian Dunn](https://twitter.com/higgaion) and +[Bash Guide for Beginners](http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html#sect_03_04_07)