Notification texts go here Contact Us Buy Now!

How to execute find command with Powershell

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

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.