Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Appendix C (continued)

Redirection Characters

|  Pipe output

The | character sends the output of one command to another command to be used as input. For example, in the line

Files | Count -l

the Files command generates a file list, then passes the list to the Count command, which counts the number of lines in the list.

∑∑  Redirect all output and append  [Option-W]

The ∑∑ operator redirects both the standard and diagnostic output of a command to a location other than the active window. If you redirect the output to a file and the file you specify does not exist, the ∑∑ operator creates it. If the file does exist, the new output is appended to its contents.

For example, the command

Files ≈.c ∑∑ Temp

lists the files in the current directory whose names end in .c and then sends all its output to the file named Temp, appending its output to the previous contents of Temp.

∑  Redirect all output and replace  [Option-W]

The ∑ operator redirects both the standard and diagnostic output of a command to a location other than the active window. If you redirect the output to a file and the file you specify does not exist, the ∑ operator creates it. If the file does exist, its contents are replaced with the new output.

For example, the command

Files ≈.c ∑ Temp

lists the files in the current directory whose names end in .c and then sends all its output to the file named Temp, replacing its contents.

≥≥  Redirect error messages and append  [Option-.]

The ≥≥ operator redirects any error messages a command might produce so that a command sends its error messages to a location other than the active window. The ≥≥ operator allows you to receive a command's standard output but "throw away" its error messages or store them somewhere else for future use. If you redirect the error messages to a file, they are appended to the file.

For example, the command

Files ≥≥ Errors

generates a list of files and directories in the current directory, displays the file list in the active window, and sends any error messages to the file named Errors. If Errors does not yet exist, the command creates it; if it does exist, the new error messages are added to the end of it.

≥  Redirect error messages and replace  [Option-.]

The ≥ operator redirects any error messages a command might produce so that a command sends its error messages to a location other than the active window. The ≥ operator allows you to receive a command's standard output but "throw away" its
error messages or store them somewhere else for future use. If you redirect the error messages to a file, the command replaces the contents of the file.

For example, the command

Files ≥ Errors

generates a list of files and directories in the current directory, displays the file list in the active window, and sends any error messages to the file named Errors. If Errors does not yet exist, the command creates it; if it does exist, its contents are replaced with the new error messages.

You can redirect error messages to the pseudodevice Dev:Null if you want to discard them, as in

Files ≥ Dev:Null

<  Redirect standard input

The < character redirects standard input so that a command takes its input from a source other than the active window. For example, if you have a file named Messages that contains a one-line message and you enter

Alert < Messages

the Alert command takes its input from the file named Messages and displays an alert box containing the text in Messages.

>>  Redirect standard output and append

The >> operator redirects standard output so that a command sends its output to a location other than the active window. One use of the >> operator is to send the output of a command to a file. If the file does not exist, the command creates it. Note that the output of the command is appended to the file's contents.

For example, the command

Files >> Filelist

generates a list of the files and directories in the current directory and appends the list to the file named Filelist. The previous contents of Filelist remain intact.

>  Redirect standard output and replace

The > operator redirects standard output so that a command sends its output to a location other than the active window. One use of the > operator is to send the output
of a command to a file. If the file does not exist, the command creates it. Note that the output of the command replaces the file's contents. If you replace the contents of a file, there is no way to retrieve the old contents.

For example, the command

Files > Filelist

generates a list of the files and directories in the current directory and stores the list in a file named Filelist, rather than displaying the list in the active window. The previous contents of Filelist are erased.

 
 


Last Updated July 2000