![test/path/to/files 목록을 prod/path/to/files 목록에 복사합니다.](https://linux55.com/image/170558/test%2Fpath%2Fto%2Ffiles%20%EB%AA%A9%EB%A1%9D%EC%9D%84%20prod%2Fpath%2Fto%2Ffiles%20%EB%AA%A9%EB%A1%9D%EC%97%90%20%EB%B3%B5%EC%82%AC%ED%95%A9%EB%8B%88%EB%8B%A4..png)
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
필요에 맞게 표현을 변경해야 할 수도 있습니다 .