====== Windows Command Line notes ====== This pages lists useful things that can be done by typing commands on a Windows computer! Notes: * All [[https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands|Windows commands]] * Commands can be typed in a ''cmd'', ''Windows PowerShell'' or, better, in a [[other:win10apps#windows_terminal|Windows Terminal]]! * //pipe// (''|'') and redirection * [[https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490982(v=technet.10)|Using command redirection operators]] * [[https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_redirection|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: [[https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/forfiles|forfiles]], [[https://en.wikipedia.org/wiki/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: * [[https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/find|find]], [[https://en.wikipedia.org/wiki/Find_(Windows)|find (Wikipedia)]] * [[https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/findstr|findstr]], [[https://en.wikipedia.org/wiki/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: [[https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/where|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 /* standard page footer */ \\ \\ \\ ---- [ [[pmip3:|PMIP3 Wiki Home]] ] - [ [[pmip3:wiki_help|Help!]] ] - [ [[wiki:syntax|Wiki syntax]] ]