Suppose that I have a directory with name xyz under /opt and
I want to copy same directory structure (without files under it) to /mnt with
directory name pqr.
/opt/xyz/
├── dir1
│ ├── f1
│ │ └── file2
│ └── file1
├── dir2
│ └── f2
│ ├── f3
│ └── file3
└── dir3
└── f4
├── f5
│ └── file5
└── file4
#rsync -a --include '*/' --exclude '*' /opt/xyz/ /mnt/pqr
or
#cd /opt/xyz && find . -type d -exec mkdir -p
/mnt/pqr/{} \;
After executing one of the above command we will get same directory structure without files as below.
/mnt/pqr/
├── dir1
│ └── f1
├── dir2
│ └── f2
│ └── f3
└── dir3
└── f4
└── f5
Reference Link: how to copy the directory structure without the files in linux│ └── f1
├── dir2
│ └── f2
│ └── f3
└── dir3
└── f4
└── f5
Good one, very helpful
ReplyDelete