Sometimes you may end up with unexpected results when running commands, so learning the “why” behind the results can be very interesting. With that in mind, today’s SuperUser Q&A post has the answer to a curious reader’s question.
Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.
SuperUser reader Luu Vinh Phuc wants to know why dir *.* lists all files and folders:
When I run the dir *.* command, it produces unexpected results. Even files and folders without any dot in the name are listed. For example:
Why is that? Is there any way to only list files with a dot?
Why does dir *.* list all files and folders?
SuperUser contributor Fleet Command has the answer for us:
The DIR command comes from a time when:
- A period (.) was not allowed as a character in file or folder names
- File and folder names were restricted to 8 characters for names and 3 characters for extensions
Therefore, by that standard, *.* meant whatever the name and whatever the extension. It did not mean a string containing a “.”, which may or may not have characters before or after the “.”.
Microsoft’s policy is preserving backward compatibility, so that interpretation of *.* is retained. But in Windows PowerShell, *.* means a string containing a “.”, which may or may not have characters before or after the “.”.
Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.
- › How to Use the DIR Command in Windows
- › 10 Things Blocking Your Wi-Fi Signal at Home
- › ExpressVPN Review: An Easy-to-Use and Secure VPN for Most People
- › 4 Ways to Ruin Your Smartphone’s Battery
- › Here’s How Mozilla Thunderbird Is Making a Comeback in 2022
- › Why Do I See “FBI Surveillance Van” in My Wi-Fi List?
- › What Can You Do With the USB Port on Your Router?