Windows Command Line notes

This pages lists useful things that can be done by typing commands on a Windows computer!

Notes:

All Windows commands

Commands can be typed in a cmd, Windows PowerShell or, better, in a Windows Terminal!

pipe (|) and redirection

Using command redirection operators

how to redirect output from PowerShell to text files

Windows equivalent of Linux commands

Sections below: Linux command ⇔ Windows command

find ⇔ forfiles

What: recursively find files (filenames) matching a given pattern

Documentation: forfiles, forfiles (Wikipedia)

Linux example: find path -n '*somename*.nc' -ls

Windows example:

PS C:\> forfiles /p C:\Utils\miniconda3_2024-03\pkgs /m *ffi*.dll /s /c "cmd /c echo @fdate @ftime @relpath"
09/11/2021 22:16:18 ".\libffi-3.4.2-h8ffe710_5\Library\bin\ffi-8.dll"
10/05/2023 13:03:16 ".\libffi-3.4.4-hd77b12b_0\Library\bin\ffi-7.dll"
10/05/2023 13:03:16 ".\libffi-3.4.4-hd77b12b_0\Library\bin\ffi-8.dll"
10/05/2023 13:03:16 ".\libffi-3.4.4-hd77b12b_0\Library\bin\ffi.dll"
11/02/2025 09:56:52 ".\libffi-3.4.6-h537db12_0\Library\bin\ffi-8.dll"
31/03/2025 17:25:29 ".\libffi-3.4.6-h537db12_1\Library\bin\ffi-8.dll"

grep ⇔ find, findstr

What: search for a string of text in a file or files

To search for a string with wild cards and regex patterns, you can use the FINDSTR command

findstr can also search subdirectories

Documentation:

find, find (Wikipedia)

findstr, findstr (Wikepedia)

Linux example:

Windows example:

which ⇔ where.exe

What: display the path of a command (look for a result in the predefined search path)

Note: on Windows, also look for files with the extensions specified in the pathext environment variable

cmd:

C:\>echo %pathext%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

Powershell:

PS C:\> echo $Env:pathext
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL

Linux search path:

$ echo $PATH
/home/share/unix_files/cdat/miniconda3_2024-03/bin:/home/share/unix_files/cdat/miniconda3_2024-03/condabin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:.

Windows search path:

cmd: echo %path%

Powershell: echo $Env:path

Documentation: where

Linux example:

(base) >which which
which: shell built-in command.
(base) >which \which
/usr/bin/which
(base) >which conda
conda: aliased to source /home/share/unix_files/cdat/miniconda3_2024-03/etc/profile.d/conda.csh

Windows example:

(base) PS C:\> where.exe where
C:\Windows\System32\where.exe
(base) PS C:\> where.exe conda
C:\Utils\miniconda3_2024-03\Library\bin\conda.bat
C:\Utils\miniconda3_2024-03\Scripts\conda.exe
C:\Utils\miniconda3_2024-03\condabin\conda.bat

[ PMIP3 Wiki Home ] - [ Help! ] - [ Wiki syntax ]