How can I list files recursively with the nu shell?
More specifically: All files, folders and everything else in a specified folder and every inner folder, recursively.
- I tried
ls **
, but that does not work. - I googled, found
ls **/**.rs
on Coming from Bash and triedls **/*
. That seemed to work, but I had to learn the hard way that it lists only some files, not all. I don't know why. But I found an example wherels **/* | where name =~ 'xxx'
found less thanls **/*xxx*
. (I thought about including my example here, to show what is listed and what not. But the folder structure is too huge.) - I cannot use
ls **/*xxx*
as I do not want to filter by name every time. Sometimes I need to filter only by other columns.
(I hope the solution is OS independent. After all, the first advantage of nu praised on its homepage is: "Nu works on Linux, macOS, and Windows. Learn it once, then use it anywhere.")
ls -a **/*
show any additional files that are missing from thels **/*
?ls -a **/*
does indeed show more files thanls **/*
.ls **/* | where name =~ 'xxx'
shows the least number of files,ls **/*xxx*
shows more andls -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, butls **/*
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".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 normalls
. Those with the hidden "attribute", however, are hidden fromls
unless the-a
option is used.ls -a **/* | where ($it.name | path basename) =~ 'xxx'