Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12.1 在没有tree命令的系统里,用find实现tree命令 #77

Open
vieyahn2017 opened this issue Dec 1, 2021 · 2 comments
Open

Comments

@vieyahn2017
Copy link
Owner

[shell] 在没有tree命令的系统里,用find实现tree命令

@vieyahn2017
Copy link
Owner Author

下面是tree命令显示的结果:
gao@gao-virtual-machine:~/test$ tree
.
|-- test1
| |-- test11
| | |-- test111
| | |-- test112
| | -- test113 | |-- test12 | -- test13
|-- test2
| |-- test21
| |-- test22
| -- test23 -- test3
|-- test31
|-- test32
`-- test33

下面是find . -print|sed -e 's;[^/]/;|--;g;s;--|; |;g' 命令出来的结果:
gao@gao-virtual-machine:~/test$ find . -print|sed -e 's;[^/]
/;|--;g;s;--|; |;g'
.
|--test3
| |--test31
| |--test33
| |--test32
|--test1
| |--test11
| | |--test111
| | |--test113
| | |--test112
| |--test12
| |--test13
|--test2
| |--test23
| |--test21
| |--test22
使用find即可实现tree的功能了,特别是在没有tree命令的系统里。。
————————————————
版权声明:本文为CSDN博主「duanyu010」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/duanyu010/article/details/84477202

@vieyahn2017
Copy link
Owner Author

vieyahn2017 commented Dec 1, 2021

find . -print|sed -e 's;[^/]*/;|--;g;s;--|;   |;g'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant