• Aucun résultat trouvé

PIPES ARD FIL~ERS

Dans le document Digital (fJ)" (Page 146-151)

MS~OOS allows you to give more than one command. to your workstation at a time by

"piping'i one command's results into another command. The

I

symbol is used to pipe two commands together. (Naturally enough, it is called a PIPE. On your keyboard it looks like a vertical line wi th a space in the middle.)

Filters read the input from a file or

command, "filter" it and then send the output to a file, another command, a printer or the CRT screen. The MS-OOS Filter commands include MORE, FIND and SORT.

MORE -- displays file or command output one screenful at a time.

DMS-SOOO 4.9 PIPES AND FILTERS

FIND -- searches for a constant string of text in a file.

SORT -- sorts text by alphabetical or numerical order.

The output from fi les and commands can also be re-directed. Usually the output would go to the CRT screen. By using the symbols

>, <,

and

»

you can:

>

direct the output of a command to a

new file or to a printer.

»

append the data to an already existing file.

<

use the data in a file as input to a command.

4.9.1 PIPING COMMANDS.

One or more commands can be piped together so that you see not the intermediate output displayed on the screen, but only the end

result. For example, you can PIPE the output of the DIR command to the MORE filter by entering the commaoo sequence:

This would have the effect of displaying the contents of your directory 23 lines at a time,

(providing, of course, that your directory had that many files in it). The command

T!PE filename

1

K>RE

Release: 4/1 /84 4-27

DMS-SOOO 4.9 PIPES AND FILTERS

would display the contents of a file 23 lines at a time.

4.9.2 FILTERS

Another example of filtering uses the SORT command. By directing the contents of a file of people's names to the SORT filter and then

redirecting the output to another file, you will have a file wi th all the names listed in

alphabetical order. The command line would look something like this:

S>RT < NAMEFILE

>

ALPIIAFILE <CR>

The SORT command can also be connected by a pipe to another command or filter. For example:

~

1

S>RT

1

K>RE <CR>

would take the output of the DIR command (the directory of a partition), sort it alphabetic-ally and then display it on the CRT 23 lines at a time.

SORT has two options (switches) that allow further manipulations of files. The /R swi tch will sort a list in reverse order. The /+n switch sorts a file starting at column +n (a number). The default number is column one if no swi tch is specified.

The FIND filter will search for a string of characters in a file and display the lines that contain the string. You must specify the string

DMS-SOOO 4.9 PIPES AND FILTERS

(in double quotes) arrl the filename(s) The format for the FIND command is:

FIND "suioj' filename <.CR>

There are three switches that allow more control over the FIND commarrl.

IV

display all lines NOT containing the specified string.

/e display the count of the number of lines that contain the specified string.

IN

displays each line that contains the specified string and the relative line number of that line in the file.

The switches are placed immediately after the word FIND in the command line. For example, the comnarrl:

DIR

1

FIND ,It n .COMn <.CR>

would search for the string .COM and display the count of how many lines it occurred in. Since the Directory has one filename per line this FIND command would give us a count of how many .CDM files were in the parti tion.

4.9.3 REDIRECTING INPUT AND OUTPUT

The TREE commarrl often will display several screens of information if your directory is large. If you want to save the output of the TREE command and view it later or edit it for

Release: 4/1/84 4-29

OMS-SOOO 4.10 CONTROL P

printing you can use the

>

symbol to direct the output of TREE to a file. The command sequence:

will place the output from the TREE directory into a file named TREEFILE.

---~---NOTE---I t is important to remember that while you can PIPE the output from one command to another command, you must redirect the output from or

into a file wi th

>, <

or

».

Use < to direct the contents of a file to a command as input (SORT < NAMEFILE).

Use

>

to direct the output of a command

into a file (OIR

>

OISKFILE).

Use

> >

to append the output from a command

to the end of an already existing file (TREE

> >

OISKFILE).

The output of an operation can also be directed to a printer. Use the

>

symbol to transfer output to a local printer or the Spool printer (OIR

>

PRN:<CR».

4.10 C~RL P ~- PRIRTIRG.

Like CP/M, MS-OOS has a CTRL function that allows you to send whatever is being displayed on the screen to a printer. (Naturally you must

DMS-5000 4.11 PRINT COMMAND

have a printer connected to the workstation or be assigned to the spool printer. See section 6 for more information on printers.)

Entering a ~ P followed by a TYPE file commaoo will seoo the contents of the file to both the printer and the screen. The file will scroll more slowly when it is being printed because the computer has to wait for the printer to 'catch up'. Everything that you enter after the CTRL P will be sent to the printer until you type another CTRL P.

CTRL/SHIFT F8 and F9 keys send everything that is already on the screen to a printer connected to the parallel port. This is called a screen dump. See section 6 for more information on using printers and the specific printers required for screen dumps.

Dans le document Digital (fJ)" (Page 146-151)

Documents relatifs