by oliwary · 4y ago · 0 comments
Aren't you just exchanging the location of relevant metadata from the path to the filename?
> ls -rec . | ? name -match <substring_in_filename>
becomes muscle memory as a pwsh daily driver-type-person (=> PowerShell 7). > 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!
find . -iname \*<substring_in_filename>*
(=> V5 Unix from 1971, although the case insensitive -iname was never standardized)