【问题标题】:Why files are displayed too for command ls even with -d flag? [closed]为什么即使带有 -d 标志的命令 ls 也会显示文件? [关闭]
【发布时间】:2023-01-28 11:55:11
【问题描述】:

来自lsman page,它说

 -d, --directory
     list directories themselves, not their contents

行动

输入指令ls -d *

预期结果

所有目录

实际结果

文件和目录显示。

环境

mac os 蒙特雷

问题

为什么会显示文件?

我知道this answer,它说要列出所有目录,我应该使用ls -d */,而*/是匹配事物的模式。

【问题讨论】:

    标签: linux


    【解决方案1】:

    在执行命令之前,* 通配符将自身扩展为当前目录中所有内容的列表。

    试试ls -d . 给你预期的结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-17
      • 2011-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-08
      • 2021-07-30
      相关资源
      最近更新 更多