我希望输出类似于
|-------File1
|-------File2
|-------Folder
|-------somefile
|-------Makefile
|-------Directory
|-------hi.txt
|-------hello.c
我正在编写一个 bash 脚本来获得这种输出。我在如何解决这个问题上遇到了麻烦。我想在不使用 tree
命令的情况下执行此操作。
最佳答案
不要重新发明轮子,这正是 tree
命令所做的。
检查 man tree
以获取详细信息。
所有流行的发行版都应该在他们的存储库中有tree
(已安装或可用);因此,如果尚未安装,您可以使用通常的方式安装它。
例如,在 Debian(和衍生产品)中:
sudo apt-get install tree
在基于 RPM 的发行版中:
sudo yum install tree
关于linux - 我怎样才能在 bash 脚本中打印目录树?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36416181/