다음 명령 시퀀스에서 cpio
이전에 보관된 파일을 추출할 수 없는 이유는 무엇입니까?
/home/pkara/Desktop/temp
$ ls
eBooks myfile.tar
/home/pkara/Desktop/temp
$ find . -depth -print | cpio -ov > backup.cpio
./backup.cpio
./myfile.tar
./eBooks/logstash_atlantis/03_output.conf
./eBooks/logstash_atlantis/02_01_filter_paloalto.conf
./eBooks/logstash_atlantis/02_02_filter_squid.conf
./eBooks/logstash_atlantis/02_99_metrics_filter.conf
./eBooks/logstash_atlantis/01_input.conf
./eBooks/logstash_atlantis
./eBooks/Container-Networking-Docker-Kubernetes.pdf
./eBooks/lpic-1_2013.pdf
./eBooks/linux-bible-by-christopher-negus.pdf
./eBooks/PythonNotesForProfessionals.pdf
./eBooks/lpic1-notes
./eBooks
.
129731 blocks
/home/pkara/Desktop/temp
$ mkdir -p foo
/home/pkara/Desktop/temp
$ mv backup.cpio foo && cd $_
/home/pkara/Desktop/temp/foo
$ cpio -iv < backup.cpio
cpio: backup.cpio not created: newer or same age version exists
backup.cpio
myfile.tar
cpio: eBooks/logstash_atlantis/03_output.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/03_output.conf
cpio: eBooks/logstash_atlantis/02_01_filter_paloalto.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/02_01_filter_paloalto.conf
cpio: eBooks/logstash_atlantis/02_02_filter_squid.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/02_02_filter_squid.conf
cpio: eBooks/logstash_atlantis/02_99_metrics_filter.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/02_99_metrics_filter.conf
cpio: eBooks/logstash_atlantis/01_input.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/01_input.conf
cpio: eBooks/logstash_atlantis: Cannot mkdir: No such file or directory
eBooks/logstash_atlantis
cpio: eBooks/Container-Networking-Docker-Kubernetes.pdf: Cannot open: No such file or directory
eBooks/Container-Networking-Docker-Kubernetes.pdf
cpio: eBooks/lpic-1_2013.pdf: Cannot open: No such file or directory
eBooks/lpic-1_2013.pdf
cpio: eBooks/linux-bible-by-christopher-negus.pdf: Cannot open: No such file or directory
eBooks/linux-bible-by-christopher-negus.pdf
cpio: eBooks/PythonNotesForProfessionals.pdf: Cannot open: No such file or directory
eBooks/PythonNotesForProfessionals.pdf
cpio: eBooks/lpic1-notes: Cannot open: No such file or directory
eBooks/lpic1-notes
eBooks
.
129731 blocks
답변1
-depth
여기서 문제는 find
. 이는 find
디렉터리 자체보다 먼저 디렉터리 내용을 처리하도록 지시합니다.
출력에서 볼 수 있듯이 find . -depth -print | cpio -ov > backup.cpio
:
./eBooks/logstash_atlantis/03_output.conf
디렉토리 이전 처리./eBooks/logstash_atlantis
./eBooks/Container-Networking-Docker-Kubernetes.pdf
이전에 처리되었습니다./eBooks
.- ...
아카이브를 추출하려고 하면 디렉터리가 아직 존재하지 않기 때문에 하위 디렉터리의 모든 파일이 실패합니다("열 수 없음: 해당 파일 또는 디렉터리가 없습니다").
또한 ./backup.cpio
디렉터리에 이미 존재하기 때문에 실패합니다.
해결책:에는 -depth
옵션을 사용 하지 마십시오 .find
cpio