Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Next: , Previous: concatenate, Up: Advanced tar


4.2.5 Removing Archive Members Using --delete

You can remove members from an archive by using the --delete option. Specify the name of the archive with --file (-f) and then specify the names of the members to be deleted; if you list no member names, nothing will be deleted. The --verbose option will cause tar to print the names of the members as they are deleted. As with --extract, you must give the exact member names when using ‘tar --delete’. --delete will remove all versions of the named file from the archive. The --delete operation can run very slowly.

Unlike other operations, --delete has no short form.

This operation will rewrite the archive. You can only use --delete on an archive if the archive device allows you to write to any point on the media, such as a disk; because of this, it does not work on magnetic tapes. Do not try to delete an archive member from a magnetic tape; the action will not succeed, and you will be likely to scramble the archive and damage your tape. There is no safe way (except by completely re-writing the archive) to delete files from most kinds of magnetic tape. See Media.

To delete all versions of the file blues from the archive collection.tar in the practice directory, make sure you are in that directory, and then,

     $ tar --list --file=collection.tar
     blues
     folk
     jazz
     rock
     practice/blues
     practice/folk
     practice/jazz
     practice/rock
     practice/blues
     $ tar --delete --file=collection.tar blues
     $ tar --list --file=collection.tar
     folk
     jazz
     rock
     $

The --delete option has been reported to work properly when tar acts as a filter from stdin to stdout.

 
 
  Published under the terms of the GNU General Public License Design by Interspire