简体   繁体   中英

How do I display a tree of things in Bash?

How do I make a tree of all things with bash? What is the command?

tree /

or

find / 

Update: @OP, since you have so much trouble with it, how about this alternative. On ubuntu 9.10, you should have bash 4.0 ? so try this

#!/bin/bash
shopt -s globstar
for rdir in /*/
do
    for file in $rdir/**
    do
      echo "$file"
    done
done
$ find . -print | sed -e 's;/*/;|;g;s;|; |;g'

在〜/ .bash_profile中添加别名

alias tree="find . -print | sed -e 's;/*/;|;g;s;|; |;g'"

you should probably alias this :)

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\\/]*\\//--/g' -e 's/^/ /' -e 's/-/|/'

(Warning: huge output)

tree -R /

and then cry because it's enormous.

On a related note, to stop the command, press CTRL + C

Assuming you want to find something from tree, do

    tree / > tree.txt

Then Ctrl + F it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM