为什么“dir c:”与“dir c:\”返回如此不同的结果?

当您了解如何使用命令行以及各种命令可以做什么时,您可能想知道,对于看起来几乎相同的命令,为什么会得到如此不同的结果。有鉴于此,今天的超级用户问答可以帮助困惑的读者理解其中的区别。...

为什么“dir c:”与“dir c:\”返回如此不同的结果?

当您了解如何使用命令行以及各种命令可以做什么时,您可能想知道,对于看起来几乎相同的命令,为什么会得到如此不同的结果。有鉴于此,今天的超级用户问答可以帮助困惑的读者理解其中的区别。

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

问题

超级用户读者Nuno Peralta想知道为什么他从几乎相同的命令中得到如此不同的结果:

I have accidentally discovered that if I use:

  • dir C:\

I get a list of files that are direct children of the C: drive (in the root). However, if I use:

  • dir C:

I get a huge list of files (dll, exe, cpl, etc.) whose location I am not even sure of.

Do you know why this happens and where this list comes from?

为什么他从几乎相同的命令中得到如此不同的结果?

答案

超级用户贡献者TOOGAM为我们提供了答案:

Specifying DIR location will show you the contents of the location. Specifying C: on many commands, including the DIR command, refers to the C Drive, and refers to the current directory. To see your current directory, type this:

  • c:
  • cd

The cd command is typically used to change which directory is c***idered the current one. However, in MS-DOS (and similar operating systems, including modern Microsoft Windows, but not including Unix), running cd by itself will show you the current directory.

In all probability, if you have not been using the cd command, then your current directory is probably the directory that your operating system was installed to (at least that is a common behavior for Microsoft Windows systems). You can do this:

  • cd “C:\Program Files”
  • cd
  • dir c:

That will show you the contents of C:\Program Files. Similarly, you can do something like copy C:*.* and all contents from the current directory will be copied.

When you specify C:\, then the backslash indicates the “root” directory, also known as the “top level” directory. That might, or might not be the same thing as your current directory.

If you just specify DIR \, then the current drive will be assumed to be the one you want. You can type something like C: or D: as an entire command on a line by itself to change which drive is c***idered the current one. If you just specify DIR, then the current drive and the current directory will be assumed to be the one you wanted.


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-09 21:10
  • 阅读 ( 97 )
  • 分类:互联网

你可能感兴趣的文章

7个强大的社交网络搜索引擎

...姓名同时优先考虑“人物页面”,而常规的Google搜索也会返回提及此人、相关标签和其他内容的帖子的结果。 ...

  • 发布于 2021-03-12 02:52
  • 阅读 ( 410 )

为什么编程语言离不开函数

... 你有没有想过为什么函数是这么多编程语言的基石?让我们看看为什么它们如此重要,以及它们为程序员做了什么。 ...

  • 发布于 2021-03-26 09:26
  • 阅读 ( 177 )

如何在microsoftexcel中使用if语句

... 使用此公式填充整个列将返回以下结果: ...

  • 发布于 2021-03-26 12:25
  • 阅读 ( 210 )

如何使用sql连接一次查询多个数据库表

...别名列名和表名,如何在一个查询中使用多个联接,以及为什么应该避免子查询。不要再试图手动将不同的数据集编译成一个数据集,开始使用连接来打动同事并节省时间。 ...

  • 发布于 2021-03-27 04:02
  • 阅读 ( 300 )

如何在excel中计算唯一值

... 我们怎么到那里有点复杂。所以,如果你想理解为什么这个公式是有效的,我们将在下面一次分解一部分。 ...

  • 发布于 2021-03-29 00:28
  • 阅读 ( 230 )

如何使用googlesheets if函数

...结果总是TRUE或FALSE。 如果If测试为TRUE,那么googlesheets将返回一个数字或文本字符串,执行一个计算,或者运行另一个公式。 如果结果是假的,它会做一些完全不同的事情。可以将IF与其他逻辑函数(如AND和OR)或其他嵌套IF语句...

  • 发布于 2021-04-02 19:05
  • 阅读 ( 214 )

如何在linux上使用look命令

...“他们”的命令,但这次是在Manjaro上。 如您所见,没有返回任何结果。但我们知道诗中有几行是以“他们”开头的 我们把文件整理一下。如果要在look中使用-f(忽略大小写)或-d(仅限字母数字字符和空格)选项,则在对文件...

  • 发布于 2021-04-03 08:14
  • 阅读 ( 207 )

如何在excel中使用逻辑函数:if、and、or、xor、not

...的截止日期是否小于今天的日期(today函数从计算机时钟返回今天的日期)。 =IF(B2<TODAY(),"Overdue",B2-TODAY()) 什么是嵌套if公式(nested if formulas)? 你以前可能听说过嵌套IFs这个词。这意味着我们可以在另一个IF函数中编写一个IF函...

  • 发布于 2021-04-03 20:24
  • 阅读 ( 324 )

如何在windows中使用dir命令

...必须使用/c开关来显示这些逗号。 如果它已经是默认值,为什么还要费心把它包含在这里呢?因为无论出于什么原因,如果你不想显示这些逗号,你可以使用这个开关和“-”减号: dir /-c   以列显示结果 可以使用/D开关将结果...

  • 发布于 2021-04-04 11:25
  • 阅读 ( 121 )

为什么windows使用反斜杠而其他所有东西都使用正斜杠

...型的斜杠并不重要。但是,有时候,区别仍然很重要。 为什么windows使用反斜杠:历史 那么为什么Windows是一个奇怪的操作系统呢?这都归结于几十年前发生的几起历史事故。 大约在1970年,Unix引入了正斜杠字符(即/字符)作...

  • 发布于 2021-04-11 11:40
  • 阅读 ( 176 )
gyesjdandhw
gyesjdandhw

0 篇文章

相关推荐