syntax:expansion:proc_subst

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
syntax:expansion:proc_subst [2014/08/21 11:27]
senseialpha Added description of substitution
syntax:expansion:proc_subst [2018/03/02 09:54] (current)
centos-hater [Avoiding subshells] Grammar fix
Line 36: Line 36:
 The **output** of the ''​ls''​-program can then be accessed by reading the file ''/​dev/​fd/​63''​. The **output** of the ''​ls''​-program can then be accessed by reading the file ''/​dev/​fd/​63''​.
  
 +Consider the following:
 +<code bash>
 +diff <(ls "​$first_directory"​) <(ls "​$second_directory"​)
 +</​code>​
 +This will compare the contents of each directory. In this command, each //process// is //​substituted//​ for a //file//, and diff doesn'​t see <(bla), it sees two files, so the effective command is something like
 +<code bash>
 +diff /dev/fd/63 /dev/fd/64
 +</​code>​
 +where those files are written to and destroyed automatically.
 ==== Avoiding subshells ==== ==== Avoiding subshells ====
 <WRAP center round info 60%> <WRAP center round info 60%>
Line 41: Line 50:
 </​WRAP>​ </​WRAP>​
  
-One of the most common uses for process substitutions ​are to avoid the final subshell that results from executing a pipeline. The following is a **wrong** piece of code to count all files in ''/​etc''​ is:+One of the most common uses for process substitutions ​is to avoid the final subshell that results from executing a pipeline. The following is a **wrong** piece of code to count all files in ''/​etc''​ is:
  
 <code bash> <code bash>
  • syntax/expansion/proc_subst.1408620448.txt
  • Last modified: 2014/08/21 11:27
  • by senseialpha