Linux 复制目录结构,不复制文件的方法

文章目录

  • 1.任务简介
  • 2. 验证/mnt下所有的目录及子目录
  • 3. 替换
  • 4.创建目录
  • 5.验证成果

1.任务简介

复制/mnt下的所有目录及子目录至/DBBACKUP/BACKUP下,而不复制任何文件

2. 验证/mnt下所有的目录及子目录

[oracle@IDPCN-IYCost BACKUP]$ find /mnt -type d
/mnt
/mnt/DUMP
/mnt/DUMP/IYCOST01-old
/mnt/DUMP/IYCOST01
/mnt/DUMP/RESTORE
/mnt/RMAN-LOG
/mnt/RMAN-LOG/IYCOST01
/mnt/RMAN
/mnt/RMAN/IYCOST01
/mnt/RMAN/IYCOST01/4
/mnt/tape
/mnt/tape/tapebackup
/mnt/tape/tapebackup/Oracle
/mnt/tape/tapebackup/Oracle/020204
/mnt/tape/tapebackup/Oracle/020204/DUMP
/mnt/tape/tapebackup/Oracle/020204/DUMP/IYCOST

3. 替换

[oracle@IDPCN-IYCost BACKUP]$ find /mnt -type d|sed 's/mnt/DBBACKUP\/BACKUP/g'
/DBBACKUP/BACKUP
/DBBACKUP/BACKUP/DUMP
/DBBACKUP/BACKUP/DUMP/IYCOST01-old
/DBBACKUP/BACKUP/DUMP/IYCOST01
/DBBACKUP/BACKUP/DUMP/RESTORE
/DBBACKUP/BACKUP/RMAN-LOG
/DBBACKUP/BACKUP/RMAN-LOG/IYCOST01
/DBBACKUP/BACKUP/RMAN
/DBBACKUP/BACKUP/RMAN/IYCOST01
/DBBACKUP/BACKUP/RMAN/IYCOST01/4
/DBBACKUP/BACKUP/tape
/DBBACKUP/BACKUP/tape/tapebackup
/DBBACKUP/BACKUP/tape/tapebackup/Oracle
/DBBACKUP/BACKUP/tape/tapebackup/Oracle/020204
/DBBACKUP/BACKUP/tape/tapebackup/Oracle/020204/DUMP
/DBBACKUP/BACKUP/tape/tapebackup/Oracle/020204/DUMP/IYCOST

4.创建目录

find /mnt -type d|sed 's/mnt/DBBACKUP\/BACKUP/g'|xargs -i mkdir -p {}

5.验证成果

[oracle@IDPCN-IYCost BACKUP]$ find /DBBACKUP/BACKUP/ -type d
/DBBACKUP/BACKUP/
/DBBACKUP/BACKUP/DUMP
/DBBACKUP/BACKUP/DUMP/IYCOST01-old
/DBBACKUP/BACKUP/DUMP/IYCOST01
/DBBACKUP/BACKUP/DUMP/RESTORE
/DBBACKUP/BACKUP/RMAN-LOG
/DBBACKUP/BACKUP/RMAN-LOG/IYCOST01
/DBBACKUP/BACKUP/RMAN
/DBBACKUP/BACKUP/RMAN/IYCOST01
/DBBACKUP/BACKUP/RMAN/IYCOST01/4
/DBBACKUP/BACKUP/tape
/DBBACKUP/BACKUP/tape/tapebackup
/DBBACKUP/BACKUP/tape/tapebackup/Oracle
/DBBACKUP/BACKUP/tape/tapebackup/Oracle/020204
/DBBACKUP/BACKUP/tape/tapebackup/Oracle/020204/DUMP
/DBBACKUP/BACKUP/tape/tapebackup/Oracle/020204/DUMP/IYCOST

你可能感兴趣的:(Linux,linux,oracle,运维)