How to execute find command with Powershell
find.exe
in Windows is not the equivalent of find
in linux.
The equivalent of find [startpath]
in PowerShell would be:
Get-ChildItem [startpath] -Name
and in cmd.exe
, it would be:
dir /B [startpath]
For an equivalent of:
find foo -type f
... I use:
Get-Children foo -Name -Recurse -File | % { $_ -replace "\\", "/" }
Use the FullName
attribute, otherwise it will not show the full name if the path is long:
(Get-ChildItem -Path 'C:\dist\work' -Force -Recurse -ErrorAction 'SilentlyContinue' -Filter "objects").FullName
C:\dist\work\bam-client\.git\objects
C:\dist\work\bam-extras\.git\objects
:
If you want to search recursively down the directory tree using wildcards (a very common pattern when using find
), try:
Get-ChildItem -Filter *.zip -Recurse $pwd