Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

process substitution <() bash

Process substitution feeds the output of a process (or processes)
into the stdin of another process

Because pipes create a new shell, $count wont be assigned
$ cat file | while read line; do ((count++)); done
$ echo $count

We can however use process subsititution to work around this:
$ while read line; do ((count++)); done < <(cat file)
$ echo $count  # the variable *does* exist in the current shell
 
PREVIOUS NEXT
Tagged: #process #substitution #bash
ADD COMMENT
Topic
Name
8+1 =