Redirect Command Output to File in MS-DOS 6.22
Redirecting command output to a text file in MS-DOS 6.22 allows you to save terminal results for logging, troubleshooting, or later review. This article explains the syntax for standard redirection, detailing how to create new files, overwrite existing ones, and append data to existing files using the command-line interface.
The Overwrite Operator
(>)
To send the output of a command to a text file, use the single
greater-than symbol (>). If the designated file does not
exist, MS-DOS creates it. If the file already exists, MS-DOS overwrites
its contents without warning.
Syntax:
COMMAND > FILENAME.EXT
Example: To redirect the directory listing of the
current folder to a file named DIRLIST.TXT:
DIR > DIRLIST.TXT
The Append Operator
(>>)
To add the output of a command to the end of an existing text file
without deleting its current contents, use the double greater-than
symbol (>>). If the file does not already exist,
MS-DOS creates a new file.
Syntax:
COMMAND >> FILENAME.EXT
Example: To append current memory status information
to an ongoing log file named SYSINFO.TXT:
MEM >> SYSINFO.TXT
Additional Redirection Practices
- Using File Paths: You can include drive letters and
directory paths to save output to specific locations:
CHKDSK C: > C:\LOGS\CHECK.TXT - Discarding Output: If you want to suppress command
output entirely instead of saving it, redirect the output to the
NULdevice:COPY FILE.DAT A:\ > NUL - Standard Error Limitation: MS-DOS 6.22 standard
command shell (
COMMAND.COM) only redirects standard output (STDOUT). Error messages generated via standard error (STDERR) will generally continue to display on the screen rather than being captured in the file.