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필요에 맞게 표현을 변경해야 할 수도 있습니다 .

관련 정보