From the course: Linux: Bash Shell and Scripts
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Using the coproc command - Linux Tutorial
From the course: Linux: Bash Shell and Scripts
Using the coproc command
- [Narrator] Let's look at some things we consider to be advanced Bash. For example, coprocesses. Coprocesses is a powerful feature where you can essentially start up a process, a process that acts like a filter, and you can write and read from the process. You're gonna get file descriptors in your shell that reference the standard in and standard out of the process. It's essentially using a pipe. So to make a coprocess, a handy thing is to write a script that can be a filter. So it's gonna read from standard in and write to standard out. Here we have a real simple one. Gonna loop forever, in effect, and it's gonna pipe the input line into the TR command. The TR command is the translate command. And with the translate command, you can give it two strings. And what it does is it translates the corresponding character from the first into the second. So if there's a capital A in the input, it'll turn it into a little a. If there's a capital B it will turn it into a little b. And so…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Using the coproc command5m 53s
-
(Locked)
Debugging scripts with -x and -u options4m
-
(Locked)
Signals and traps4m 14s
-
(Locked)
Using the eval and getopt commands6m 47s
-
(Locked)
Challenges: Debugging scripts using trap, eval, getopt, and coproc2m 49s
-
(Locked)
Solutions: Debugging scripts using trap, eval, getopt, and coproc7m 22s
-
(Locked)
-