Powershell

Search file or directory

in the simplest form:

ls . -Filter your_file_or_dir -Recurse

Of course the output can be piped for more magic, eg:

ls . -Filter your_file_or_dir -Recurse | % { $_.FullName }

Breakdown:

  • ls (or dir or gci) = alias for Get-ChildItem cmdlet
  • . = shorthand for the current directory path
  • -Filter = file system path to search for, wildcards are supported
  • -Recurse (or -r) = search also the nested directory structure.
  • | = pipe which routes the output of the 'ls' cmd to the following expression
  • % = shorthand for the foreach-object
  • $_ = shorthand for $PSItem = the current argument for the currently executing script block, in this case each file system object that matches the filter