Is it possible to remove all files that start with certain name from a compressed tarball without extracting and recreating the archive again?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The tar file format is a streaming format, so it would be possible to do this by reading the old file, skipping over the unwanted file(s), and copying all the data you want to keep to a new tar file. If the tar file is also compressed (eg.
.tar.gz), then you would have to uncompress, filter, recompress, and write.I don’t know of any existing tools to do this, but it should be reasonably straightforward using the Python
tarfilemodule, for example.