I’m trying to copy a directory structure(not the files) for backup and migration. I’ve been searching all over but I don’t quite know how to phrase my search to get the results I want. I keep finding people mentioning the following commands the second being closest to what I am trying to get. I need to make sure it runs in KSH and BASH.
ls -Rl |egrep '^d'
and
find / -type d -print
An example of the file structure and how I’d like to get a list of all the lowest(?) directories with their full path prefix.
/var/www
└── site
├── dir1
│ ├── dir11
│ ├── dir12
│ ├── dir13
│ │ └── dir131
│ └── dir14
├── dir2
└── dir3
├── dir31
└── dir32
└── dir321
├── dir3211
└── dir3212
##### Will generate the following list. #####
/var/www/site/dir1/dir11
/var/www/site/dir1/dir12
/var/www/site/dir1/dir13/dir131
/var/www/site/dir1/dir14
/var/www/site/dir2
/var/www/site/dir3/dir31
/var/www/site/dir3/dir32/dir321/3211
/var/www/site/dir3/dir32/dir321/3212
Thank you,
LF4
Doing ls -R | grep ./ will give the list of all directories and subdirectories and could be fed into something else which will mkdir for all the entries.
This assumes you are in the directory /var/www/html. You could alter the grep so that instead of ./ it uses /var/www/html or whatever.