New directions. (redirecting data in Amiga computers)
by Jim Butterfield
Most CLI commands and many programs send output to the standard CLI window. That output may be redirected to a device or file by using the greater-than symbol (>). Some programs and a few CLI commands create a custom window in which to do work. When this happens, as with the Ed text editor, redirection isn't useful. Output can be redirected only if it would normally go to the standard CLI console window.
It's possible to redirect input, too, if that input is normally typed in the CLI window. This is done by means of the less-than (<) symbol. Input redirection is comparatively rare; most commands get everything they need from the command line you use to launch them.
Some CLI-only programs are written to take all their input data from the standard console, which is your CLI window. They expect you to redirect this input, so as to take their data from a file you specify.
A few programs take this a step further. They expect you to redirect both the input and the output. Such programs are called filters; they aren't common on the Amiga. In the future, Commodore may introduce a new feature called command line piping. When that happens, filter programs will be very useful, and you'll see more of them.
NIL: the road to nowhere. The Amiga has a logical device called NIL:, which may be thought of as a "nowhere file." It's a popular target for redirection. Anything sent to NIL: is thrown away, and if you try to read information from NIL:, you'll get nothing.
Here's an example command to show how NIL: works. If you type Copy >NIL: DFO: To RAM:, you're asking the Amiga to copy all files from your internal disk drive's root directory to the RAM disk. The files come from DFO: and are sent to RAM:, so what goes to the NIL: device? The messages that normally print on the screen as the copies are made. Sending Copy's output to NIL: causes that output to be thrown away instead of printed on the screen. Incidentally, you would get the same effect if you typed Copy Quiet DFO: to RAM:. Compare the above example with typing Copy MyFile To NIL:. In this case, we're not using redirection. Copy's output will show on the screen, but the file itself is copied to "nowhere." It seems illogical to copy a file yet not copy it. But if you want to check that a file isn't damaged due to a bad spot on your disk, copying the file to NIL: will do the job. Although the destination file is thrown away, every byte of the file will have been read, and Copy will report an error if the file is mangled.
Incidentally, NIL: actually works more like a file than a drawer or device. You can't type Copy RAM: to NIL: or use a similar command using pattern matching. You can send individual files to NIL:, but not groups of them.
The logical opposite of that command, Copy NIL: To MyFile, is allowable. This command creates an empty file, containing no data. One use for an empty file is as a starting point to which you can append data. We'll talk about appending to a file in a moment.
Nothing in, nothing out. It seems odd, but some programs redirect both input
and output to the NIL: device. In your startup-sequence file, you might see
something like Run>NIL: Here's what's happening: The Amiga still see a process called Ed that has an
input and output path to that CLI window. It refuses to close the window until
Ed is gone. It makes no difference that Ed will never use the window; the
pathway is there, and the Amiga won't take any chances.
Go back to Ed, hit the Esc key, and then press Q. Both Ed and the CLI window
will now vanish. The Amiga recognizes that the window no longer has any users.
Let's do it again, but this time we'll break the path to the CLI window. Type
Run > NIL: