Member-only story
In Unix systems, pipes and redirections are the bridges that join our programs. They are an underrated resource that can aid developers in their own work in powerful ways.
Today’s post will explore pipes from their humble beginnings to how we use them in our programs (with example help from Golang).
Humble beginnings
Let’s start with the humble pipe operator |
. If you are running a Unix shell, we can explore the pipe operator with some simple examples:
In this short example, we are echoing “Hello friends” and using a pipe to pass that output to the translate characters program tr
and taking all the lower case letters and upper casing them!
If you are unfamiliar with
tr
, runman tr
to see more. The description includes information on[:class:]
usage.
In fact, we could add more pipes if we wanted to “glue” together more programs. We could even just do that with passing out put back to translate
again!