ICT306 Pipes and Filters in MS-DOS

This may assist in deeper understanding of topic 1 and in doing the lab practice for week 2.


UNIX was designed around a pipe and filter architecture. Some of these ideas are available in DOS. To get a DOS prompt under Windows you may find a shortcut or you may need to type in "command" or “cmd” under the Run option under START.

Lines of text which need to be processed can come from text files but also from directory listings. Use "dir /b" (at the DOS prompt) to get a list of the names of the files in the current directory one per line.

For help on using DOS, eg moving around the directory structure (which is the same as the Windows Folder structure) see, eg, here.

See the topic 1 slides for instructions on how to pipe in DOS and how to redirect input and output, eg feed a text file into a pipe.


Grep is used to find all lines in a specified file (or files) which contain some string (or pattern of characters).

It can be used to look in files in the current directory, eg, grep Expn *.txt lists all the lines in any '.txt' file in the directory which contains the string (or pattern) “Expn”.

It can be used to look in any input file, eg, dir | grep Expn lists each of the files in the current directory whose name contains “Expn”.

In either case, the argument “Expn” to grep can be a simple string or a pattern described in a simple language. The patterns are called regular expressions.

NOTE: If you do not have access to GREP, you can use the DOS command FINDSTR which emulates GREP. For information on FINDSTR, enter FINDSTR/? at the DOS prompt.

Regular Expressions

Full details of regular expressions can be found at many places on the Web. Examples of their use (usually in UNIX-- so not all the examples are directly relevant to DOS) can be found here and here.

Note that in DOS it is best to quote the expression inside double quotes to prevent special characters being interpreted by DOS.

Here are some examples,

Note: as "." as a special meaning you need to write "\." if you want to specify the full-stop character. In general backslash ("\") before a character switches of its special meaning.

Note: "$" can be used to indicate the end of a line in the same way as "^" indicates the beginning.

Note: "[^xyz]" matches any character except "x", "y" and "z".

Try a few examples in your first practice class.