TAR - delete from an archive

by
Jeremy Canfield |
Updated: September 01 2021
| TAR articles
Let's say you've created a tar archive named example.tar, and the tar archive contains the contents of the /tmp directory.
tar -cf example.tar /tmp
The tar command with the -t or --list and -f or --file optiions can be used to view the contents of the tar achive.
tar -tf example.tar
Let's say the following is returned, meaning that example. tar contains two files, foo.txt and bar.txt.
tmp/
tmp/foo.txt
tmp/bar.txt
The --delete option can be used to remove files from the tar archive. In this example, bar.txt will be removed.
tar --delete --file example.tar tmp/bar.txt
Did you find this article helpful?
If so, consider buying me a coffee over at