dir不列出子文件夹
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.
有时您在运行命令时可能会得到意想不到的结果,因此了解结果背后的“原因”可能非常有趣。 考虑到这一点,今天的SuperUser Q&A帖子回答了一个好奇的读者的问题。
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提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。
问题 (The Question)
SuperUser reader Luu Vinh Phuc wants to know why dir *.* lists all files and folders:
超级用户读者Luu Vinh Phuc想知道为什么dir *。*列出所有文件和文件夹:
When I run the dir *.* command, it produces unexpected results. Even files and folders without any dot in the name are listed. For example:
当我运行dir *。*命令时,它会产生意外的结果。 甚至会列出名称中没有任何点的文件和文件夹。 例如:
Why is that? Is there any way to only list files with a dot?
这是为什么? 有什么办法只列出带点的文件吗?
Why does dir *.* list all files and folders?
为什么目录*。*列出所有文件和文件夹?
答案 (The Answer)
SuperUser contributor Fleet Command has the answer for us:
超级用户贡献者舰队司令部为我们提供了答案:
The DIR command comes from a time when:
DIR命令来自以下时间:
- 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 文件和文件夹名称的名称限制为8个字符,扩展名的限制为3个字符
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 “.”.
Microsoft的策略是保留向后兼容性,因此保留对*。*的解释。 但是在Windows PowerShell中,*。*表示包含“。”的字符串,该字符串在“。”之前或之后可能没有字符。
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.
有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程 。
翻译自: https://www.howtogeek.com/301185/why-does-dir-list-all-files-and-folders/
dir不列出子文件夹