mirror of
https://github.com/tldr-pages/tldr.git
synced 2024-10-28 15:19:43 +01:00
parent
6d55cba78b
commit
444c78c805
2 changed files with 60 additions and 0 deletions
28
pages.nl/common/coproc.md
Normal file
28
pages.nl/common/coproc.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# coproc
|
||||
|
||||
> Bash ingebouwd commando voor het maken van interactieve asynchrone subshells.
|
||||
> Meer informatie: <https://www.gnu.org/software/bash/manual/bash.html#Coprocesses>.
|
||||
|
||||
- Voer een subshell asynchroon uit:
|
||||
|
||||
`coproc { {{commando1; commando2; ...}}; }`
|
||||
|
||||
- Maak een coprocess met een specifieke naam:
|
||||
|
||||
`coproc {{naam}} { {{commando1; commando2; ...}}; }`
|
||||
|
||||
- Schrijf naar de `stdin` van een specifiek coprocess:
|
||||
|
||||
`echo "{{invoer}}" >&"${{{naam}}[1]}"`
|
||||
|
||||
- Lees van de `stdout` van een specifiek coprocess:
|
||||
|
||||
`read {{variabele}} <&"${{{naam}}[0]}"`
|
||||
|
||||
- Maak een coprocess dat herhaaldelijk `stdin` leest en opdrachten op de invoer uitvoert:
|
||||
|
||||
`coproc {{naam}} { while read line; do {{commando1; commando2; ...}}; done }`
|
||||
|
||||
- Maak en gebruik een coprocess dat `bc` uitvoert:
|
||||
|
||||
`coproc BC { bc --mathlib; }; echo "1/3" >&"${BC[1]}"; read output <&"${BC[0]}"; echo "$output"`
|
32
pages.nl/linux/coproc.md
Normal file
32
pages.nl/linux/coproc.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
# coproc
|
||||
|
||||
> Bash ingebouwd commando voor het maken van interactieve asynchrone subshells.
|
||||
> Meer informatie: <https://www.gnu.org/software/bash/manual/bash.html#Coprocesses>.
|
||||
|
||||
- Voer een subshell asynchroon uit:
|
||||
|
||||
`coproc { {{commando1; commando2; ...}}; }`
|
||||
|
||||
- Maak een coprocess met een specifieke naam:
|
||||
|
||||
`coproc {{naam}} { {{commando1; commando2; ...}}; }`
|
||||
|
||||
- Schrijf naar de `stdin` van een specifiek coprocess:
|
||||
|
||||
`echo "{{invoer}}" >&"${{{naam}}[1]}"`
|
||||
|
||||
- Lees van de `stdout` van een specifiek coprocess:
|
||||
|
||||
`read {{variabele}} <&"${{{naam}}[0]}"`
|
||||
|
||||
- Maak een coprocess dat herhaaldelijk `stdin` leest en opdrachten op de invoer uitvoert:
|
||||
|
||||
`coproc {{naam}} { while read line; do {{commando1; commando2; ...}}; done }`
|
||||
|
||||
- Maak een coprocess dat herhaaldelijk `stdin` leest, een pipeline uitvoert op de invoer, en de uitvoer naar `stdout` schrijft:
|
||||
|
||||
`coproc {{naam}} { while read line; do echo "$line" | {{commando1 | commando2 | ...}} | cat /dev/fd/0; done }`
|
||||
|
||||
- Maak en gebruik een coprocess dat `bc` uitvoert:
|
||||
|
||||
`coproc BC { bc --mathlib; }; echo "1/3" >&"${BC[1]}"; read output <&"${BC[0]}"; echo "$output"`
|
Loading…
Reference in a new issue