4 ms·
For me, > ls -rec . | ? name -match <substring_in_filename> becomes muscle memory as a pwsh daily driver-type-person (=> PowerShell 7).
by AceyMan 5y ago
For me,
> ls -rec . | ? name -match <substring_in_filename>
becomes muscle memory as a pwsh daily driver-type-person (=> PowerShell 7).
- DHowett 5y agoFor simple matches against one pattern, you may prefer... > ls -rec . -filter *substring*` ... as filtering can be offloaded to the "provider" when Get-ChildItem (ls) knows about it. Even if the filesystem provider doesn't handle patterns any differently from Where-Object (?), you can save the cost of hydrating FileInfo objects only to query and discard most of them. For multiple patterns or anything that you'd need a regular expression for, Where-Object is superior!
- AceyMan 5y agoThanks, I'm not usually doing performance required stuff but when I write a function I always want to know the best way to feed the pipeline, I appreciate it. #snoverville
- tremon 5y agoaka find . -iname \*<substring_in_filename>* (=> V5 Unix from 1971, although the case insensitive -iname was never standardized)