But say you want to save a copy of the output from the command that was executed. For example when using ipconfig to view the TCP configuration of your computer network card (NIC) or executing the dir command to view a list of directories.
One way is to copy from the command prompt window and paste it in a text file. Unfortunately, this can be cumbersome at times.
Instead, there is a better way to easily capture the output directly from the command prompt window to a file by using the redirection command.
To use the redirect command, just use the symbol > (press Shift + greater than arrow) and the file name at the end of the command you want to execute.
For example to redirect output of the ipconfig command to the file tcpinfo.txt, enter the following command at the prompt:
ipconfig /all > tcpinfo.txt
This will create the file called tcpinfo.txt in the current directory you are at (shown in below screen shot), with the output results of ipconfig command.
If you want the file created at another location on your hard drive, enter the full path to that location:
ipconfig /all >c:\mystuff\tcpinfo.txt
When using a single redirect command, it will always over-write (delete) the contents of the file (unless you specify a different file name) before writing any new data.
If you want to append (concatenate) data to an existing file, use two redirection symbols as shown in the following example:
dir c:\mymusic >> c:\tcpinfo.txt
This example adds the output of the dir (directory) command to the end of the file - tcpinfo.txt.
Now, you are not limited to redirecting output to a file. You can also redirect to devices such as a printer.
Say you have a printer connected to LPT1. You would use the following command:
dir c:\mymusic >LPT1
You can also use PRN or CON to output data results. Just make sure the device is working correctly.
No comments:
Post a Comment
Hey Guys! Thanks for visiting my blog. Hope you enjoy reading. Just leave your comments if you think this post is a worth readable! Your valuable comments are always welcomed. Please don't spam! and No abusive language would be tolerated. I would moderate your feedback and then it would be published. If you have any query I will try to give feedback as soon as possible.