List all directories recursively in a tree format

前端 未结 5 1934
春和景丽
春和景丽 2020-12-28 09:47

I want to simulate a tree command using Shell Script that displays all the directories recursively in this format:

.
|-- Lorem
|-- Lorem
|-- Lor         


        
5条回答
  •  情歌与酒
    2020-12-28 10:03

    Modified base on the awk one from http://www.unix.com/shell-programming-scripting/50806-directory-tree.html

    pwd;find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i

    Output looks more similar to tree:

    /etc
    ├── sudoers.d
    ├── susehelp.d
    │   ├── htdig
    ├── sysconfig
    │   ├── SuSEfirewall2.d
    │   │   ├── services
    │   ├── network
    │   │   ├── if-down.d
    │   │   ├── if-up.d
    │   │   ├── providers
    │   │   ├── scripts
    │   ├── scripts
    ├── sysctl.d
    ├── systemd
    │   ├── system
    │   │   ├── default.target.wants
    │   │   ├── getty.target.wants
    │   │   ├── multi-user.target.wants
    

提交回复
热议问题