📌  相关文章
📜  进程替换 <() bash - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:43.559000             🧑  作者: Mango

代码示例1
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