How to Send the Output of the Command Line to a File


This tip was stimulated by a question from Donavan about the previous tip.

When you use the command line, the output is normally sent to the screen. However, you can send the output to a file instead by using one of the two redirection symbols ">" and ">>". This can be handy when you want to keep a record of the output. For example, the command:

ipconfig > C:\newlist.txt

Will create a new text file C:\newlist.txt and send the results of the command ipconfig to this new file. If you want to append the output to the contents of an already existing file the command is:

ipconfig >> C:\oldlist.txt

In the examples, I have used ipconfig but any command that outputs text can be used. I gave a previous instance in the tip on listing your files of a given type,

The output file can be located anywhere but a full path must be specified. If no path for the file is given, it will be created in the working directory of the command prompt. Usually, a text file with extension .txt is used. However, I have also sent output to word processor files with extensions like .doc 

Get your own favorite tip published!  Know a neat tech tip or trick?  Then why not have it published here and receive full credit?  Click here to tell us your tip.

This tips section is maintained by Vic Laurie. Vic runs a Windows blog called The PC Informant and also operates a computer education website.

Click here for more items like this. Better still, get Tech Tips delivered via your RSS feeder or alternatively, have the RSS feed sent as email direct to your in-box.

Please rate this article: 

Your rating: None
Average: 3.7 (19 votes)