windows CMD 树命令限制级别数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31927324/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:12:52  来源:igfitidea点击:

CMD tree command limit number of levels

windowscmdtree

提问by iqover9000

How do I limit the number of levels that the tree command goes through in Windows? I need to output the results to a text file for work, but because by default the tree command lists every single directory under the one you ran the command in, the output I'm getting is over 44,000 lines long, which isn't helpful at all for my work. How do I restrict it to listing just the first couple levels?

如何限制 tree 命令在 Windows 中经过的级别数?我需要将结果输出到一个文本文件以供工作,但是因为默认情况下 tree 命令列出了您运行该命令的目录下的每个目录,所以我得到的输出超过 44,000 行,这没有帮助完全是为了我的工作。我如何限制它只列出前几个级别?

回答by Dariusz Sikorski

Since I didn't found complete answer here. Here it is:

因为我没有在这里找到完整的答案。这里是:

Windows CMD doesn't support -Ldepth levels.

Windows CMD 不支持-L深度级别。

  1. Install CygWin https://www.cygwin.com.
  2. In Cygwin make sure you pick Utilities / Tree package installed.
  3. Open CygWin and navigate to your folder, like cd ../../cygdrive/c/myFolder.
  4. List tree structure and save as result.txt tree -L 3 >result.txt.
  1. 安装 CygWin https://www.cygwin.com
  2. 在 Cygwin 中,确保你选择了 Utilities / Tree 安装包。
  3. 打开 CygWin 并导航到您的文件夹,例如 cd ../../cygdrive/c/myFolder
  4. 列出树结构并保存为 result.txt tree -L 3 >result.txt

回答by Jesse Chen

Actually, treecommand in DOS does not have the leveloption. You can refer the manual: tree in windows.

实际上,treeDOS 中的命令没有level选项。您可以参考手册:windows 中的树

But, you can use the git bash(this is a tool provided by git when you installed the git on windows) or babun(it's a really good tool for windows user to use the *unix tools) so in this way, you can use the command that @Zhengquan Feng mentioned.

但是,您可以使用git bash(这是在 Windows 上安装 git 时由 git 提供的工具)或babun(它是 Windows 用户使用 *unix 工具的非常好的工具),因此通过这种方式,您可以使用以下命令@Zengquan Feng 提到了。

回答by Willard Wong

You can try this project on Windows :

你可以在 Windows 上试试这个项目:

https://github.com/MrRaindrop/tree-cli

https://github.com/MrRaindrop/tree-cli

Usage:

用法:

use -llevelNumber to specify the path level:

使用-llevelNumber 指定路径级别:

treee -l 2

treee -l 2

回答by Newt

  1. Try to download WSLin your Windows system.

  2. In your command prompt:

    bash

  3. Then you can use Linux commands:

    tree -L x(the layer)

  1. 尝试在您的 Windows 系统中下载WSL

  2. 在您的命令提示符中:

    bash

  3. 然后你可以使用 Linux 命令:

    tree -L x(the layer)