Centos Directory Structure as Tree

CentOS directory structure as tree?

As you can see here. tree is not installed by default in CentOs, so you'll need to look for an RPM and install it manually

How can i get the tree style directory in linux centos to text file

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

Linux command to print directory structure in the form of a tree

Is this what you're looking for tree? It should be in most distributions (maybe as an optional install).

~> tree -d /proc/self/
/proc/self/
|-- attr
|-- cwd -> /proc
|-- fd
| `-- 3 -> /proc/15589/fd
|-- fdinfo
|-- net
| |-- dev_snmp6
| |-- netfilter
| |-- rpc
| | |-- auth.rpcsec.context
| | |-- auth.rpcsec.init
| | |-- auth.unix.gid
| | |-- auth.unix.ip
| | |-- nfs4.idtoname
| | |-- nfs4.nametoid
| | |-- nfsd.export
| | `-- nfsd.fh
| `-- stat
|-- root -> /
`-- task
`-- 15589
|-- attr
|-- cwd -> /proc
|-- fd
| `-- 3 -> /proc/15589/task/15589/fd
|-- fdinfo
`-- root -> /

27 directories

sample taken from maintainer's web page.

You can add the option -L # where # is replaced by a number, to specify the max recursion depth.

Remove -d to display also files.

Creating a full directory tree at once

Change shebang to

#!/bin/bash

to run the script with bash as it supports brace expansion.

The problem is that you are using shell that does not support it. Your /bin/sh does not point to /bin/bash but to something like /bin/dash.

https://wiki.ubuntu.com/DashAsBinSh#A.7B

Show directory structure of a Python project?

In the Windows command prompt

cd path/to/ROOT
tree /f

or if you want to export this tree to a file, use this command

tree /f > tree.txt

then open tree.txt

In Linux/MacOS terminal

First, you should install package name tree

  • In MacOS: brew install tree
  • In RHEL/CentOS/Fedora: yum install tree
  • In Debian/Mint/Ubuntu: sudo apt-get install tree

Then run this command:

tree /path/to/ROOT

Copy folder structure (without files) from one location to another

You could do something like:

find . -type d > dirs.txt

to create the list of directories, then

xargs mkdir -p < dirs.txt

to create the directories on the destination.



Related Topics



Leave a reply



Submit