If I have a number of directories, named, for example 10001 through 10025 is there any reason to use ls 1*/foo vs. ls 100??/foo?I have a lot more than 25 of them, so I mostly curious if there's any differences in speed.I know the difference in use between the two, that the asterisk will match longer file names, like 10001.backup. But let's say I don't have any files that don't follow my conventions. Is there any behind-the-scenes differences?
Is there a reason to use multiple question marks instead of an asterisk in filename expansion?
wildcards
FunctionThey mean different things. The asterisk matches zero to infinity characters. The question mark matches exactly one character.From the references above:The * character serves as a wild card for filename expansion in globbing.The ? character serves as a single-character wild card for filename expansion in globbingPerformancetl;dr: there is no detectable difference in performance.I tested performance by using a directory filled with 36 sub-directories, each named with a single character. There were about 70 000 files in the subdirectories combined. I tested the following.$ time ls ?/* -d >/dev/null$ time ls */* -d >/dev/nullI alternated each command ten times each. Here are the results for the real time, in seconds.?       *0.318   0.3260.355   0.2120.291   0.3510.291   0.2650.287   0.2830.362   0.230.248   0.330.286   0.2830.293   0.3510.233   0.352After statistical analysis (paired t-test, two-tailed), I could detect no difference between the two values in performance (p value = 0.95).EDIT: More samplesI repeated the above analysis with 200 samples each, again alternating tests.$ for i in {1..200}; do time (ls */* -d >/dev/null) 2>> /tmp/time_asterisk; time (ls ?/* -d >/dev/null) 2>> /tmp/time_question_mark; doneHere are the raw data for ? and *. Again, I could detect no significant difference (p value = 0.55), and the distribution of each test looks more similar.