LoginSignup
2
0

More than 1 year has passed since last update.

対象ファイルのリストを読み込んでrsyncする

Last updated at Posted at 2022-03-22

やりたいこと

例えばこんなディレクトリがあったとする。

parent/
├── child1
│   ├── grandchild1
│   └── grandchild2
└── child2
    ├── grandchild1
    └── grandchild2

このうち

parent/
├── child1
│   └── grandchild1
└── child2
    └── grandchild2

だけを取り出したい。

やり方

rsyncしたい対象のファイルが書かれたリストを用意する

parent/child1/grandchild1
parent/child2/grandchild2

--files-from=[ファイルリストの絶対パス]を使ってrsync

rsync --files-from=PATH_TO_FILE SOURCE DESTINATION

ファイルの中身はSOURCEからの相対パスになることに注意。例えばparentがカレントディレクトリの直下にある場合はこうなる

rsync --files-from=file_list.txt . destination
# 結果
destination/
└── parent
    ├── child1
    │   └── grandchild1
    └── child2
        └── grandchild2
2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0