Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 1
    Thanks for reposting here. And yes, the solution should be platform independent, but there are definitely platform specific bugs (although I don't know that this is one), so I like to try to reproduce under the OS in question when possible. Commented May 13, 2022 at 19:39
  • 1
    Just to confirm, this isn't a case of the file being hidden (or in a hidden directory), right? Does ls -a **/* show any additional files that are missing from the ls **/*? Commented May 13, 2022 at 19:54
  • Good point! ls -a **/* does indeed show more files than ls **/*. ls **/* | where name =~ 'xxx' shows the least number of files, ls **/*xxx* shows more and ls -a **/* | where name =~ 'xxx' shows the most files. In my example, ls **/*xxx* lists files in folders where one of the enclosing folders has a name that starts with a dot, but ls **/* does not. Adding the *xxx* constraint therefore increases the number of matches. ls -a **/* | where name =~ 'xxx' additionally lists every file in a directory whose name contains "xxx".
    – user194860
    Commented May 13, 2022 at 20:30
  • Ok, that's interesting -- For me, ls **/*xxx* ignores files in hidden directories (Linux/WSL2). Also, just tried on Windows Nushell -- This is definitely an area where OS-specific behavior is present. On Windows, directories and files that start with a dot are displayed by default with just a normal ls. Those with the hidden "attribute", however, are hidden from ls unless the -a option is used. Commented May 13, 2022 at 20:57
  • Oh, and to get it to ignore files in directories that match (but still display the directory name if it matches), ls -a **/* | where ($it.name | path basename) =~ 'xxx' Commented May 13, 2022 at 21:00