test/path/to/files リストを prod/path/to/files リストにコピーします。

test/path/to/files リストを prod/path/to/files リストにコピーします。

test/path/to/file/filename.xyz 形式のファイルのリストを対応する実稼働パス prod/path/to/file/filename.xyz にコピーしたいと思います。 "test"の代わりに "prod"があることを除いて、テストパスと本番パスが同じ場合は、次のコマンドを使用できますか?ターゲットファイルを上書きしますか?

$ xargs -I % --arg-file=input.txt cp /test/% /prod/%

ベストアンサー1

input.txt 内容を次のように編集します。 (参考+

+ /path/to/file/filename.xyz

次に、

rsync -amv \
  --include '*/' \
  --include-from input.txt \
  --exclude '*' \
  test/ prod/

たとえば、すぐにファイルを編集して直接実行することもできます。

rsync -amv \
  --include '*/' \
  --include-from <(sed 's/^/+ /' input.txt) \
  --exclude '*' \
  test/ prod/

sed必要に応じて表現を変更する必要があるかもしれません。

おすすめ記事