blank.gif (43 bytes)

Church Of The
Swimming Elephant

Search:
index.gif

ntcmds00000000.gif

Filter Commands

Filter commands help you sort, view, and select parts of the output of a command.

Passing Information Through Filter Commands

Filter commands divide, rearrange, or extract portions of the information that passes through them. Windows NT has three filter commands:

ntcmds00000002.gif The more command displays the contents of a file or the output of a command one screen at a time.

ntcmds00000002.gif The find command searches through files and command output for the characters you specify.

ntcmds00000002.gif The sort command alphabetizes files and command output.

To send input from a file to a filter command, use the less-than sign (<). If you want the filter command to get its input from another command, use the pipe (|).

Controlling the Screen Display by Using the More Command

The more command displays the contents of a file or the output of a command one screen at a time. For example, the following more command displays the contents of the LIST.TXT file one screen at a time:

more < list.txt

After a screen of information is displayed, the word "More" appears. To continue to the next screen, press any key. To stop the command without viewing more information, press CTRL+C.

The more command is helpful if you are working with a command that produces more than one screen of output. For example, suppose you want to view a directory tree for your hard disk. If you have more directories than Windows NT can display on the screen, you can use the tree command with a pipe (|) and a more command, as in the following example:

tree c:\ | more

The first screen of output from the tree command is displayed, followed by the word "More." Windows NT pauses until you press any key (except the PAUSE key).

Searching for Text by Using the Find Command

The find command searches one or more files for the text you specify. Windows NT displays every line containing that text. The find command can be used as a filter command or as a standard Windows NT command. For information about using find as a standard Windows NT command, see find.

To use find as a filter command, include a less-than sign (<) and a filename to search through. (The search is case-sensitive.) For example, the following command finds occurrences of the string "Pacific Rim" in the file TRADE.TXT:

find "Pacific Rim" < trade.txt

To save the output of the find command rather than display it, use a greater-than sign (>) and the name of the file that is to store the output. For example, the following command finds occurrences of "Pacific Rim" in the TRADE.TXT file and saves them in the NWTRADE.TXT file:

find "Pacific Rim" < trade.txt > nwtrade.txt

Sorting Text Files

The sort command alphabetizes a text file or the output of a command. For example, you would use the following command to sort the contents of a file named LIST.TXT and display the results on your screen:

sort < list.txt

In this example, the sort command sorts the lines of the LIST.TXT file and displays the results without changing the file. To save the output of the sort command rather than display it, include a greater-than sign (>) and a filename in the command. For example, you would use the following command to alphabetize the lines of the LIST.TXT file and store the results in the ALPHLIST.TXT file:

sort < list.txt > alphlist.txt

To sort the output of a command, type the command followed by a pipe (|) and the sort command. For example, the following command sorts the output of the find command:

find "Jones" maillst.txt | sort

When you type this command, Windows NT lists in alphabetic order the lines in which the string "Jones" appears.

Combining Commands with Redirection Characters

You can combine filter commands, other commands, and filenames to make custom commands. For example, you could use the following command to store the names of files that contain the string "LOG":

dir /b | find "LOG" > loglist.txt

Windows NT sends the output of the dir command through the find filter command and stores the filenames that contain the string "LOG" in the LOGLIST.TXT file. The results are stored as a list of filenames (for example, A.LOG, LOGDAT.SVD, and MYLOG.BAT).

To use more than one filter in the same command, separate the filters with a pipe (|). For example, the following command searches every directory on drive C, finds the filenames that include the string "LOG", and displays them one screen at a time:

dir c:\ /s /b | find "LOG" | more

Because you use a pipe (|), Windows NT sends the output of the DIR command through the find command. The find command selects only filenames that contain the string "LOG". The more command displays the filenames that are selected by the find command, one screen at a time.

Cotse.Net

Protect yourself from cyberstalkers, identity thieves, and those who would snoop on you.
Stop spam from invading your inbox without losing the mail you want. We give you more control over your e-mail than any other service.
Block popups, ads, and malicious scripts while you surf the net through our anonymous proxies.
Participate in Usenet, host your web files, easily send anonymous messages, and more, much more.
All private, all encrypted, all secure, all in an easy to use service, and all for only $5.95 a month!

Service Details

 
.
www.cotse.com
Have you gone to church today?
.
All pages ©1999, 2000, 2001, 2002, 2003 Church of the Swimming Elephant unless otherwise stated
Church of the Swimming Elephant©1999, 2000, 2001, 2002, 2003 Cotse.com.
Cotse.com is a wholly owned subsidiary of Packetderm, LLC.

Packetderm, LLC
210 Park Ave #308
Worcester, MA 01609