Linux / Unix: Tarball Delete ( remove ) File

Linux / Unix: Tarball Delete ( remove ) File

To delete a file from a tarball (a file archive created with the tar command), you can use the tar command with the --delete option. For example, if you have a tarball named mytar.tar and you want to delete a file named file.txt from it, you can use the following command:

refe‮ r‬to:lautturi.com
tar --delete -f mytar.tar file.txt

This will delete the file file.txt from the tarball mytar.tar.

Keep in mind that this will only delete the file from the tarball and not from the file system. If you want to delete the file from the file system as well, you will need to use a separate command, such as rm file.txt.

Note: The --delete option is not available on all versions of tar. If you are using an older version that does not support this option, you can extract the tarball, delete the file, and create a new tarball with the tar command and the --create option.

tar -xf mytar.tar
rm file.txt
tar -cf mytar.tar *

This will extract the tarball, delete the file file.txt, and create a new tarball with the same name as the original, but with the file removed.

Created Time:2017-10-29 22:08:59  Author:lautturi