Command Prompt Tricks | Redirection in Command Prompt


Good Morning To all,
You Know DOS Shell is One of the important part in Administration. So Today I will Teach You Important part of cmd, that is Redirection. There are Two operators > and >>

These little characters let you redirect the output of a command to a file :), giving you a saved version of whatever data the command produced in the Command Prompt window.


Examples:

ipconfig  > networksettings.txt


In this example, I save all the network configuration information that I'd usually see on screen after running ipconfig to a file by the name of networksettings.txt.

As you can see, the > redirection operator goes between the ipconfig command and the name of the file I want to store the information in. If the file already exists, it'll be overwritten. If it doesn't already exist, it will be created.

ping 10.1.23.123 > "C:\Users\Princy\Desktop\Ping Results.txt"


Here, I execute the ping command and output the results to a file by the name of Ping Results.txt located on my desktop, which is at C:\Users\Princy\Desktop. I wrapped the entire file path in quotes because there was a space involved.

ipconfig /all >> \\server\files\netsettings.log


This example uses the >> redirection operator which functions in much the same way as the > operator, only instead of overwriting the output file if it exists, it appends the command output to the end of the file.
Now It is clear that >> redirection operator is really useful when you're collecting similar information from multiple computers or commands and you'd like to store all data in a single file.

1 comment:

Any Query, Suggestion Please Comment Here