<SOLVED> how to list all directory&files within a directory using tree command??????

smooth_buddha

Active Member
Joined
Feb 13, 2020
Messages
362
Reaction score
246
Credits
1,648
hey guys learning commandline and created diretories

mkdir -p this/is/a/test/of/making/directories/within/dircetories

i wanted to know a command to list everything under "this" directory.
i realise using the ls command on "this" will list the directory within "this" but not everything else under the path.

i googles and found the command tree which works is exactly what i was looking to do but i had to sudo apt install tree becase it was not already on my system.

is there something im missing?? is there also another command already built in to list the full tree of directory???? why did i have to install the command ?? is it not native to linux mint which is what im running????
 


Typically the tree command is NOT installed by default in most distros. But they usually have it in their repos. So you can install it if required.

Also, it is possible to recursively list the contents of a directory using ls. Try this:
Bash:
ls -R ./this/
That will recursively list the contents of everything inside ./this/

If you want to find out about the other capabilities of the ls command, try taking a look at its man-page, or its info page using the commands man ls or info ls, respectively!
 
thanks for this! i got caught out with the recursive -r , i tried man pages for ls before finding tree command. i must have used a lower case instead of capital andi forgot the the ./ before the directory.

thanks agian! i knew there must of been a way built into tlinux to list the tree without having to download the tree from the repo
 
thanks for this! i got caught out with the recursive -r , i tried man pages for ls before finding tree command. i must have used a lower case instead of capital andi forgot the the ./ before the directory.

thanks agian! i knew there must of been a way built into tlinux to list the tree without having to download the tree from the repo
The ./ wasn't really the important thing - the important thing was the -R (recursive) option.
I automatically added ./ because I was assuming that you were in the directory containing the "this" directory.

If you were in the directory where the "this" directory is then this would also work:
Bash:
ls -R this
Because the ./ is implicit!

If you weren't in the directory where the "this" directory is then you would either need to use a fully qualified path
e.g.
Bash:
ls -R /path/to/this

Or use a relative path (using . and/or ../).
e.g.
if you were in the /path/to/that/something/ directory and you wanted to recursively list /path/to/this - you could use a relative path like this:
Bash:
ls -R ../../this
 

Members online


Latest posts

Top