Previous Next Chapter

Redirection

Redirection can change input or output to a specific file or device (such as printer, modem, or logical device). When working in the Shell, the keyboard is the source of command input a nd the current Shell window is the destination for output. You can redirect input and output using the left angle bracket, right angle bracket, and asterisk characters.

Angle Brackets

A redirection argument consists of either the < or > symbol followed by a file name or device name. The angle bracket must be preceded by a space, but no trailing space is necessary.

For some commands, the redirection characters can replace the keywords TO and FROM, depending on the command's syntax.

You can only redirect input or output on the command line in which the redirection characters appear. AmigaDOS applies the default input and output sources for any subsequent commands without redirection.

Right Angle Bracket (>)

The right angle bracket redirects the console output of a command to the destination pointed to by the bracket. The console output is the text that the command prints in the Shell window when executed. For example:

1> DIR >Testfile DF0:

sends a directory listing of DF0: to a file in the current directory called Testfile. Testfile is created if it does not already exist and it contains the directory listing as ASCII text. The directory listing is not displayed on the screen.

Only the console output of a command is redirected, not the data on which the command works. For example:

1> COPY >Log Picdir TO PicsArchive: ALL

copies all the files in the Picdir directory to the PicsArchive disk, sending a list of the copied file names to the Log file.

Left Angle Bracket (<)

To change the source of a command's input from the keyboard to a file, use the < symbol. However, a question mark (?) must also be used as a separate argument on the command line. The question mark instructs the command to accept input; it is not a wildcard character in this context. The following example creates a file and then uses the contents of the file as the argument for a command:

1> ECHO tomorrow TO Datefile
1> DATE ? <Datefile

The ECHO command creates a file called Datefile containing the word "tomorrow". The DATE command accepts the contents of Datefile (the word "Tomorrow") as if it were entered at the keyboard. This sts the system date 24 hours ahead.

Double Right Angle Brackets (>>)

Redirect output and append material to an existing file using two output symbols (>>) with no spaces between them. For example:

1> Postscript >>Laser/Letter

executes the program Postscript, adding its output to the end of the Laser/Letter file.

Asterisk (*)

An asterisk refers to the current Shell window. However, to avoid confusion with other use of the asterisk, we recommend using CONSOLE:, which is the synonym for *. The asterisk can be used as a FROM or TO argument or as a redirection file name (the source of input or the output destination).

Pressing Ctrl+\ restores input/output to the default source. For example:

1> COPY * TO Screenfile

or

1> COPY CONSOLE: TO Screenfile

copies all subsequent text typed in the current window to the file called Screenfile until you press Ctrl+\.

Ctrl+\ is also used to close a Shell window. Be careful not to press this key combination twice when you want to end the redirection since it also closes the Shell window.

Top Previous Next Chapter