Append Output to Text Files in MS-DOS 6.22
In MS-DOS 6.22, redirecting command line output is essential for logging and file management. This guide explains the exact syntax required to append output to an existing text document without overwriting its current contents, compares it to the standard overwrite operator, and provides practical command examples for immediate use.
The Append Redirection Syntax
To append data to an existing text file in MS-DOS 6.22, use the
double greater-than redirection operator (>>).
The standard syntax is:
command >> filename.txtcommand: The DOS utility or internal command generating the output (such asDIR,TYPE, orECHO).>>: The append operator, which redirects standard output (STDOUT) to the end of a destination file.filename.txt: The path and name of the file to receive the data.
If the specified file already exists, the new output is added directly to the end of the file. If the file does not exist, MS-DOS 6.22 automatically creates it.
The Difference Between
> and >>
Understanding the distinction between the single and double redirection operators prevents unintentional data loss:
- Single Arrow (
>): Overwrites the file. Ifoutput.txtalready contains text,DIR > output.txtcompletely erases the previous contents and replaces them with the new directory listing. - Double Arrow (
>>): Appends to the file. RunningDIR >> output.txtpreserves all existing text and adds the new directory listing to the very bottom of the document.
Practical Examples
1. Appending Directory Listings
To log the contents of a directory to an existing master inventory file:
DIR C:\GAMES >> C:\LOGS\GAMES.TXT2. Appending Custom Text Lines
To add a specific line of text or a timestamp marker to a log file
using the ECHO command:
ECHO System check completed >> STATUS.LOG3. Combining Multiple Files into One
To combine the contents of one text file onto the end of another
without using the COPY command:
TYPE UPDATE.TXT >> MASTER.TXTThis ensures that all information within UPDATE.TXT is
appended cleanly to the end of MASTER.TXT.