开发者

How do I display a tree of things in Bash?

开发者 https://www.devze.com 2022-12-23 02:05 出处:网络
How do I make a tree of all things wit开发者_运维技巧h bash? What is the command?tree / or find /

How do I make a tree of all things wit开发者_运维技巧h 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


you should probably alias this :)

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

(Warning: huge output)


$ find . -print | sed -e 's;/*/;|;g;s;|; |;g'

Add alias to ~/.bash_profile

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消