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
CMD tree command limit number of levels
提问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 -L
depth levels.
Windows CMD 不支持-L
深度级别。
- Install CygWin https://www.cygwin.com.
- In Cygwin make sure you pick Utilities / Tree package installed.
- Open CygWin and navigate to your folder, like cd
../../cygdrive/c/myFolder
. - List tree structure and save as result.txt
tree -L 3 >result.txt
.
- 安装 CygWin https://www.cygwin.com。
- 在 Cygwin 中,确保你选择了 Utilities / Tree 安装包。
- 打开 CygWin 并导航到您的文件夹,例如 cd
../../cygdrive/c/myFolder
。 - 列出树结构并保存为 result.txt
tree -L 3 >result.txt
。
回答by Jesse Chen
Actually, tree
command in DOS does not have the level
option. You can refer the manual: tree in windows.
实际上,tree
DOS 中的命令没有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 -l
levelNumber to specify the path level:
使用-l
levelNumber 指定路径级别:
treee -l 2
treee -l 2