CentOS上有没有相当于树的?
正如你在这里看到的。 树在默认情况下并不安装在CentOs中,因此您需要查找RPM并手动安装
如果你的Centos系统上没有安装树(我通常建议服务器设置无论如何都要使用最小的安装盘),你应该在命令行输入以下内容:
# yum install tree -y
如果这没有安装,那是因为你没有正确的存储库。 我会使用Dag Wieers仓库:
http://dag.wieers.com/rpm/FAQ.php#B
之后,你可以做你的安装:
# yum install tree -y
现在你已经准备好了。 总是阅读手册页: http : //linux.die.net/man/1/tree
所以很简单,以下将返回一棵树:
# tree
或者,您可以将其输出到文本文件。 还有很多的选择..再次,如果你正在寻找除默认输出之外的东西,请阅读你的手册页。
# tree > recursive_directory_list.txt
(^^在文本文件中供以后查看^^)
你可以使自己的原始“树”(为了好玩:))
#!/bin/bash # only if you have bash 4 in your CentOS system shopt -s globstar for file in **/* do slash=${file//[^\/]} case "${#slash}" in 0) echo "|-- ${file}";; 1) echo "| |-- ${file}";; 2) echo "| | |-- ${file}";; esac done
你在基地回购中有树。
显示它(yum list package-name):
# yum list tree Available Packages tree.i386 1.5.0-4 base
安装它:
yum install tree
(在CentOS 5和6上验证)
由于tree
在CentOS中默认没有安装…
[user@CentOS test]$ tree -bash: tree: command not found [user@CentOS test]$
您还可以使用以下ls
命令来生成与tree
几乎相似的输出
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
例:
[user@CentOS test]$ ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' . |-directory1 |-directory2 |-directory3 [user@CentOS directory]$