Windows 10 Windows 10 dir search using wild char "?" is not returning expected output

  • Thread starter Thread starter VBahirji
  • Start date Start date
V

VBahirji

Hi,


I noticed some strange behavior when I did directory search (using command line) with wild char "?". Wild char "?" is supposed to match any single character so e.g. if you use "??" it should match two single chars and "???" should match exactly 3 single chars. However, "???" matches 1, 2 and 3 chars instead. I did the same dir search on Mac and Linux and they provide the correct out. here is an example :

  • I have three files in a dir (1.sav, 12.sav and 123.sav).
  • command "dir ?.sav" returns only 1.sav as expected.
  • command "dir ??.sav" returns 1.sav and 12.sav.. this is not expected. It should only return 12.sav
  • command "dir ???.sav" returns all three 1.sav, 12.sav, 123.sav.... this is not expected. It should only return 123.sav
  • Tested this on mac/linux and all the three commands return exactly one results (with matching single char for each "?" wild char).


Take a look at the screen shot below for the experiment I ran.


Can you provide feedback on this observation ? if this expected result, then I would like to understand how "?" is treated as wild char for dir search in Windows. If not, is this a bug ?




Continue reading...
 
Back
Top