How can I use the tree command to list current directory as a tree?
If I do
tree -L 1
It only lists the directories, how can I get it to show the files as well?
command linelinuxtreeUbuntu
How can I use the tree command to list current directory as a tree?
If I do
tree -L 1
It only lists the directories, how can I get it to show the files as well?
Best Answer
For Windows XP or 7, the
/F
switch will also show filenames.However, I'm guessing you're on another OS since
/L
is not a valid switch on XP or 7.On my Ubuntu VM (11.10),
tree
did not come pre-installed.sudo apt-get install tree
fixed that quickly. Afterwardstree -L 1
worked just as you seem to want it to - it showed a tree of just the current directory, including files and directories. Adding the-a
switch also included "hidden" files. It seems the default behavior oftree
is to show both files and directories. This can be changed to directories only with the-d
switch.More details can be found in
man tree
or here: http://www.computerhope.com/unix/tree.htmIf you're having trouble, I suggest checking the
ls
of yourpwd
to make sure there actually are files in that directory. Also, check your file and folder permissions and view theman
page fortree
for more options.