複数のファイルまたはディレクトリを除外しながらファイルまたはディレクトリをコピーする

複数のファイルまたはディレクトリを除外しながらファイルまたはディレクトリをコピーする
[@ysx-dlfwq-2 555]$ tree
.
├── 666
├── 777
│   └── 71.sh
├── 888
│   └── 8881
├── test2.sh
├── test.sh
└── test.txt

4 directories, 4 files

After executing the command
find /opt/share/555/ -mindepth 1 -type d \( -path /opt/share/555/666 -o -path /opt/share/555/888/8881 \) -o -type f \( -path /opt/share/555/test.txt \) -prune -o -exec cp -prf {} /opt/share/2/ \;

[@ysx-dlfwq-2 2]# tree
.
├── 71.sh           <<<----Files that should not appear
├── 777
│   └── 71.sh
├── 888
│   └── 8881        <<<----Directory that should not appear
├── test2.sh
└── test.sh

3 directories, 4 files

私たちの環境では組み込みのシステムコマンドしか使用できず、rsync は考慮されていません。現在私が知っている正規表現をサポートするコマンドがない場合は、専門家の皆さんに助けていただけないでしょうか?

答え1

何を達成しようとしているのか少し不明ですが...

findコピーするファイルのリストを生成し、それを渡してgrepフィルタリングし、結果をパイプしてcpio実際にファイルをコピーするために使用できます。

find /opt/share/555/ -type f |
  grep -v 'whatever' |
  cpio -pd /opt/share/2

これにより、正規表現を使用して、何をコピーするか、何をコピーしないかを制御できます。

関連情報