Junk Drawer Logo Junk Drawer

For all those little papers scattered across your desk

I/O Funnels

D. Ben Knoble on 23 Aug 2019 in Blog

I teach a lab, and think of a new way to teach I/O redirection operators.

Problems to solve

We are software engineers, and we like to automate. We would prefer to automate:

Inputting entries for a program all day long is a boring job. So is copy-pasting the output into emails, as input for other programs, or as a test.

Solutions

Files. It’s files all the way down.

Input

We normally just type input while the program is running. We want to automate that. We use the < operator:

cmd <file

It sucks in the contents of file and funnels it as input to cmd

Output

Output is normally sent to the console screen. We usually want to capture it and do something with it. We use the > operator:

cmd >file

It sucks the output of cmd and funnels it to file

You can combine them, too:

cmd <in >out
cmd >out <in
<in cmd >out
<in >out cmd

&c.


Tags:

Categories: Blog

Load Comments
Previous Next
Back to posts