Skip to Content
A stick figure smiling

Here's a preview from my zine, Bite Size Bash! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".
read the transcript!

sometimes you want to send the output of one process to the input of another

$ ls | wc -1
53

(53 files!)

a pipe is a pair of 2 magical file descriptors

ls -> stdout -> IN -> pipe -> OUT -> stdin -> wx

(IN and OUT are file descriptors)

panel 3

when ls does
write(IN, "hi")

wc can read it!
read(OUT)-> "hi"

Pipes are one way. You can’t write to OUT

the OS creates a buffer for each pipe

IN -> data waiting to be read -> OUT

when the buffer gets full:

process, represented with by a box with a smiley face: write(IN, "..."
OS, represented by a box with a nonplussed face: it’s full! I’m going to pause you until there’s room again,

named pipes

you can create a file that acts like a pipe with mkfifo

$ mkfifo mypipe 
$ ls > mypipe & 
$ wc < mypipe

(this does the same thing as ls | wc)

you can use pipes in other languages!

only shell has the syntax process1 | process2 but you can create pipes in basically any language!