How can I get all the files inside `/var` and its subdirectories and ignore listing out folder name?
How can I get all the files inside /var and its subdirectories but at the same time, ignoring list out subdirectory folder name?
I have tried Dir["/var/*"] but it doesn't list all the files inside sub directory.
The ** that appears in this pattern matches any path fragment of zero or more nested directories, but doesn't match files.
Let's break that down:
When you have /var/somefile.txt (which likely doesn't exist on your system, because /var most likely only has directories in it), here's what each part of your glob would match:
Part of pattern Part of directory path /var /var ** (nothing) * somefile.txt
For the file /var/run/NetworkManager.pid:
Part of pattern Part of directory path /var /var ** run * NetworkManager.pid
For the file /var/spool/mail/news:
Part of pattern Part of directory path /var /var ** spool/mail * news
I'm not sure what Dir['/var/**'] on its own does. I think that to make it work the way you expect, you always need another path component after the **.