如何复制多个子文件夹中多个目录中存在的文件两级?

时间:2016-10-13 11:17:50

标签: linux shell unix cassandra datastax

我正在将包含多个子文件夹的30个密钥空间文件夹中的快照文件复制到两个级别的文件夹中。 我想为所有嵌套文件夹做这件事:

来自目录的

<?php 

class RDBConnection{
private $host,$user,$password,$dbname;
public $dbh,$sth;
function __construct(){
   $this->host="localhost";
   $this->user="user";
   $this->password="pass";
   $this->dbname="zczc";
}
// connect method create connection
function connect(){
    try{
  $this->dbh=new PDO("mysql:host=$this->host;dbname=$this->dbname",$this->user,$this->password);
  // set the PDO error mode to exception
  //$this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }
    catch (PDOException $e){
        echo $e->getMessage();
    }
}
// disconnect method disconnect connection created
function disconnect(){
    $this->dbh=null;
}
// insert
function inserMenu($menu){
    $this->sth=$this->dbh->prepare("INSERT INTO menucategory (menu_type,menu_order,menu_status) VALUES (?,?,?)");
    $this->sth->bindParam(1, $menu[0]);
    $this->sth->bindParam(2, $menu[1]);
    $this->sth->bindParam(2, $menu[2]);
    $this->sth->execute();
   return true;
}
}
?>

到目录

/data/disk01/keyspace1/table1/snapshots/1475505658586/*

我的命令将遍历所有&#34;键空间&#34;命名文件夹,并进入它的每个子文件夹,然后将文件复制两级。

仅供参考,我们有30个密钥空间文件夹(example- keyspace1,keyspace2 ......等等,表格如table1,table2,table3,...等等,disk1,disk2,disk3,disk4&amp; disk5)。

如何从文件夹&#34; / 1475505658586&#34;中复制文件?在/桌上达到两级? 一个命令应该执行所有复制作业。

1 个答案:

答案 0 :(得分:1)

这应该有用。

cd /data/disk01/keyspace1/table1/snapshots/1475505658586
cp -ar keyspace* ../..