ECN No Name Newsletter: February, 1990

The ECN No Name Newsletter is no longer being published. This is an archived issue.

[previous article] [next article]

Rediretion Meta Characters

Stacey Clark

Here are two special meta characters "<" and ">" that allow redirection. The "<" takes input from a file and the ">" puts output into a file. For example, if you have compiled a program as an executable, say a.out, then you can type :

   $ a.out

The program may ask for data on the screen. If you are debugging the program and typing the same data over and over, you may want to type the data into a file. This way you can just specify the filename, instead of interactively typing the data in at the terminal.

This would be done like :

   $ a.out < input

If you need to mail a SMALL file to someone, you can use redirection too!

   $ mail login < small.file

Please note that if you mistakenly type: $ mail login > small.file

YOU WILL CLOBBER YOUR FILE !!

What the ">" does is capture the output into a file. For example,

   $ a.out > output

So, the moral of the story is don't use ">" and "<" unless you can remember that the words flow in the direction the arrow is pointing!!

A safer way to send files via mail is:

   $ mail login
     subject: Here is the recipe
     ~r recipe.file


webmaster@ecn.purdue.edu
Last modified: Friday, 24-Oct-97 13:37:40 EST

[HTML Check] HTML