# Windows command line

Help
C:\>help dir
C:\>dir /?
Echo
C:\>echo on
C:\>echo off
C:\>echo Test
C:\>echo.
C:\>@help rem
Regular expressions
C:\>dir *.txt
C:\>dir ???.txt
Redirections
C:\>echo x > file01.txt
C:\>pause < file01.txt
C:\>type file02.txt 2> error.txt
C:\>type file03.txt > output_error.txt 2>&1
Filters
C:\>echo x | pause
C:\>dir | more
C:\>dir | sort | more
C:\>findstr "good night" file04.txt
Environment variables
C:\>set | more
C:\>set var1=1
C:\>ser var2=2
C:\>set var
C:\>set var1=
C:\>set var2=
C:\>set path=%path%;dir01
C:\>echo %computername%
C:\>echo %date%
C:\>echo %time%
C:\>echo %errorlevel%
C:\>echo %number_of_processors%
C:\>echo %os%
C:\>echo %path%
C:\>echo %pathext%
C:\>echo %processor_architecture%
C:\>echo %processor_identifier%
C:\>echo %processor_level%
C:\>echo %processor_revision%
C:\>echo %random%
Copy files
C:\>rem Copy files and directories recursively
C:\>xcopy /?
Compare files
C:\>rem Compare
C:\>comp file1 file2
C:\>rem Compare
C:\>fc file1 file2
Adjusting de cmd
C:\>rem Size
C:\>mode 120x120
C:\>rem Color [0xbackground, 0xforeground]
C:\>color 0a
C:\>rem Window title
C:\>title Network info
Directory listing
C:\>tree /a /f C:\
Scripts
C:\>type script.cmd
@echo off
rem script.cmd
cls
echo.
echo Script name: %0
echo First parameter: %1
echo Second parameter: %2
for %%i in (*.txt) do type %%i
C:\>script p1 p2
Escape
C:\>echo a is ^> than b
Flux control
C:\>call script.cmd %1 %2
C:\>cmd /k dir
C:\>start dir
C:\>for %i in (*.txt) do type %i
C:\>for /D /r %i in (*) do @echo dir: %i
C:\>for /R %i in (*.bak) do del %i
C:\>for /L %i in (1,1,10) do @echo %i
C:\>echo "a 1" >> file05.txt
C:\>echo "b 2" >> file05.txt
C:\>echo "c 3" >> file05.txt
C:\>for /F "tokens=1,2" %i in (file05.txt) do @echo t2=%j t1=%i
C:\>for /F "delims=: tokens=1-2 usebackq" %i in (`time /t`) do @echo %i:%j
C:\>type file06.txt
@echo off
goto message2
echo message1
:message2
echo message2
C:\>if not exist file07.txt echo "No file"
C:\>exit /b 0

No comments: