Question

I have the directories and then subdirectories inside it.

How can i export the directory tree with custom depth level and then export that to a text file

basically i am looking for shell function

printTree(level)

so i get one text file like this

Dir1
-------file1
-------file2
-------dir1
-------dir2

Dir12
----------file1

How can i do that

Était-ce utile?

La solution

sudo yum install tree

tree Dir1 and you will get a result such as

Dir1
├── Dir11
│   ├── Dir111
│   └── Dir112
├── Dir12
└── Dir13
    └── Dir131

6 directories, 0 files

then you can use tree Dir1 > mytreefile.txt to export that to a text file named mytreefile.txt

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top