I encounter one problem about the file system in the shell.
what’s difference between tmp/**/* and tmp/*?
I make the experiment in my system,
have this directory dir2
dir2
-->dir1
-->xx2
-->ff.txt
and I run ls dir2/*:
dir2/ff.txt
dir2/dir1:
xx2
then I run ls dir2/**/*:
dir2/dir1/xx2
So it means the ** is to ignore this directory(like ignore the dir1),
Can some one help me ?
I think there’s a formatting issue in the question test, but I’ll answer based on the question title and examples.
There shouldn’t be any difference between a single and double asterisk at any single level of the path. Either expression matches any name, except for hidden ones which start with a dot (this can be changed by shell options). So:
tmp/**/*(equivalent totmp/*/*) is expanded to all names which are nested two levels deep intmp. The first asterisk expands only to directories and not files at the first level because it’s followed by a slash.tmp/*expands to anything nested one level deep insidetmp.To this comes the fact that
lswill list contents of directory if a directory is given on its command line. This can be overridden by adding-doption tols.