How do I display a tree of things in Bash?
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.
精彩评论