I like to use the following code to emulate the Unix “find” behavior:
ls DIRECTORY -recurse -include PATTERN | foreach { "$_" }
In fact, there are a couple of other commands that I’d like to append this | foreach { "$_" } to. So I’m trying to find a way to make this easier to type. I tried stuff like this:
function xfind {
ls $args | foreach { "$_" }
}
And then I invoked it like so:
xfind DIRECTORY -recurse -include PATTERN
But that seemed to do the wrong thing…
Consider simply to use the
-nameswitch of theGet-ChildItem(akals,dir):This way is native, clean, and effective.