Hello! There is an archive packed with tar -cpvf which needs to be unpacked into a directory that already contains some of the files from the archive. Question: How to unpack it without replacing the files that are already in the directory?
2 answers
man tar -k, --keep-old-files don't replace existing files when extracting, |
Judging by man tar , you need the -k(--keep-old-files) switch -k(--keep-old-files)
-k, --keep-old-files saves existing files and does not overlap them when extracting archive objects
Those. the call will be
tar xfkv archive.tar /path/to/extract/ Script to check:
#!/bin/bash # читаем справку #man tar # Создаем директорию для теста mkdir tmp mkdir tmp/dir # наполняем файлами touch tmp/file0.txt touch tmp/file1.txt touch tmp/dir/file0.txt # создаем архив tar cf tmp.tar tmp # удалим часть файлов rm tmp/file0.txt # распакуем без замены tar xfkv tmp.tar |
--keep-old-files. More options - gbg