tree命令报错引发的思考与启示

ubuntu@shenzhen:~ $ tree .
sed: read error on .: Is a directory
ubuntu@shenzhen:~ $ command tree

Command 'tree' not found, but can be installed with:

sudo apt install tree

ubuntu@shenzhen:~ $ sudo apt install tree
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  tree
0 upgraded, 1 newly installed, 0 to remove and 63 not upgraded.
Need to get 43.0 kB of archives.
After this operation, 115 kB of additional disk space will be used.
Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu focal/universe amd64 tree amd64 1.8.0-1 [43.0 kB]
Fetched 43.0 kB in 0s (2,654 kB/s)
Selecting previously unselected package tree.
(Reading database ... 115945 files and directories currently installed.)
Preparing to unpack .../tree_1.8.0-1_amd64.deb ...
Unpacking tree (1.8.0-1) ...
Setting up tree (1.8.0-1) ...
Processing triggers for man-db (2.9.1-1) ...
ubuntu@shenzhen:~ $ tree .
sed: read error on .: Is a directory
ubuntu@shenzhen:~ $ command tree .
.
├── a
├── A

0 directories, 2 files
ubuntu@shenzhen:~ $ type tree
tree is aliased to `find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g''

原因是因为ubuntu里面并不自带tree命令,刚开始输入的tree只是bash-it实现的一个别名,然后bash-it存在bug它只能运行最原始的不带参数的tree所以报错,要查看命令的本质可以使用type命令,要直接执行原生的命令可以使用command命令。

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页