파일 이름 목록에서 파일을 복사하고 기존 파일을 무조건 대상에 유지하는 방법은 무엇입니까?

파일 이름 목록에서 파일을 복사하고 기존 파일을 무조건 대상에 유지하는 방법은 무엇입니까?

파일 이름 목록에서 파일을 복사하고 기존 파일을 무조건 대상에 유지하는 방법은 무엇입니까?

cpio는 기본적으로 기존 파일을 덮어씁니다.

$ dpkg -L libgcc1 libstdc++6 |grep -e '^/lib/' -e '^/usr/lib/' |  cpio -pdv ./test
./test/lib/i386-linux-gnu
cpio: ./test/lib/i386-linux-gnu/libgcc_s.so.1 not created: newer or same age version exists
./test/usr/lib/i386-linux-gnu
cpio: ./test/usr/lib/i386-linux-gnu/libstdc++.so.6.0.22 not created: newer or same age version exists
cpio: ./test/usr/lib/i386-linux-gnu/libstdc++.so.6 not created: newer or same age version exists
0 blocks
$ touch -ht 200102030405 $(find  . )
$ dpkg -L libgcc1 libstdc++6 |grep -e '^/lib/' -e '^/usr/lib/' |  cpio -pdv ./test
./test/lib/i386-linux-gnu
./test/lib/i386-linux-gnu/libgcc_s.so.1
./test/usr/lib/i386-linux-gnu
./test/usr/lib/i386-linux-gnu/libstdc++.so.6.0.22
./test/usr/lib/i386-linux-gnu/libstdc++.so.6
3222 blocks
$ #same version
$ dpkg -L libgcc1 libstdc++6 |grep -e '^/lib/' -e '^/usr/lib/' |  cpio -pdv ./test
./test/lib/i386-linux-gnu
cpio: ./test/lib/i386-linux-gnu/libgcc_s.so.1 not created: newer or same age version exists
./test/usr/lib/i386-linux-gnu
cpio: ./test/usr/lib/i386-linux-gnu/libstdc++.so.6.0.22 not created: newer or same age version exists
cpio: ./test/usr/lib/i386-linux-gnu/libstdc++.so.6 not created: newer or same age version exists
0 blocks
$ cp --version
cp (GNU coreutils) 8.26
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
$ 

답변1

이를 수행할 방법이 없습니다 cpio.

그러나 이를 사용하여 star작업을 완료할 수 있습니다. 그냥 전화하세요:

star -xpk < archive-name

참고: GNU cpio가 올바르게 작동하는지 잘 모르겠지만 cpio에는 먼저 파일을 임시 이름으로 추출하고 성공하면 rename(2)비파괴적인 성적 모드를 호출하여 이전 이름을 대체하는 문서화되지 않은 함수가 있기 때문에 시스템 관리에 자주 사용됩니다. 파일 모드. 따라서 공식 cpio(GNU cpio일 필요는 없음)은 install프로그램처럼 작동합니다.

별표와 함께 이 동작을 원하면 이 -install옵션을 추가하세요.

관련 정보