Answers for "process substitution <() bash"

1

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
Posted by: Guest on October-03-2021

Browse Popular Code Answers by Language