安装
需求:
打印出当前目录的文件结构
命令:
tree -Cd -L 5
tree命令的中文意思为“树”,功能是以树形结构列出指定目录下的所有内容,包括所有文件、子目录及子目录里的目录和文件。
报错
01
root@iZ8vbfxqax8z5y6femcwxaZ:~/baidu#
Command 'tree' not found, but can be installed with:
apt install tree
原因: 看来系统是ubuntu,系统默认没有安装tree命令
apt install tree
02
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
google-chrome-stable : Depends: fonts-liberation but it is not going to be installed
Depends: libappindicator3-1 but it is not going to be installed
Depends: libasound2 (>= 1.0.16)
Depends: libatk-bridge2.0-0 (>= 2.5.3) but it is not going to be installed
Depends: libatspi2.0-0 (>= 2.9.90) but it is not going to be installed
Depends: libgtk-3-0 (>= 3.9.10) but it is not going to be installed
Depends: libx11-xcb1 but it is not going to be installed
Depends: libxtst6 but it is not going to be installed
Depends: xdg-utils (>= 1.0.2) but it is not going to be installed
Recommends: libu2f-udev but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
原因: 系统包有损坏,来修复这些安装包就行了
apt --fix-broken install
03
......
E: Failed to fetch http://mirrors.cloud.aliyuncs.com/ubuntu/pool/main/m/mesa/libgl1-mesa-glx_19.0.8-0ubuntu0~18.04.3_amd64.deb 404 Not Found [IP: 100.100.2.148 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
原因:包向source里的资源下载失败了,但是原因是多种多样的,首先根据提示操作
apt-get update
问题解决
root@iZ8vbfxqax8z5y6femcwxaZ:~/baidu# apt-get update
Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu bionic InRelease
......
Get:23 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6/multiverse amd64 Packages [13.0 kB]
Fetched 8,552 kB in 3s (2,952 kB/s)
Reading package lists... Done
tree的常规使用
- 查看帮助:
tree --help
- 常用参数
其中常用参数:
- -a:打印全部文件。
- -A:使用ASNI绘图字符显示树状图而非以ASCII字符组合(显示的树状图为实线不是虚线)。
- -C:在文件和目录清单加上色彩,便于区分各种类型。
- -d:只打印目录。
- -L level:指定打印目录的深度(层级)。
- -f:打印出每个文件、目录的绝对路径。
还可以在树状目录结构中打印出文件的所属用户和uid、所属组和gid、文件大小、文件修改时间等