Guide to Windows Commands/Tips and Tricks

      This page contains tips for when you are using the windows command prompt. Some of these tips will not be immediately obvious so it's worth giving this module a quick read.

      Create an Empty File

      TYPE NUL > EmptyFile.txt
      

      Continue a Line

      The caret '^' is the escape character in cmd.exe. It can be used to continue a command across a line end if it is the last character on a line.

      C:\>ECHO Hello ^
      More? World
      Hello World
       
      C:\>
      

      Replacing a String in a File

      FOR /F "delims=^$" %%i IN (server.txt) DO (
          SET NEW=%%i
          SET NEW=!NEW:^<HOST_NAME^>=%COMPUTERNAME%!
          ECHO !NEW!
      )
      
      Last modified on 22 February 2011, at 03:32