www.delorie.com/gnu/docs/tar/tar_55.html   search  
 
Buy GNU books!


GNU tar

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2.6 Removing Archive Members Using `--delete'

(This message will disappear, once this node revised.)

You can remove members from an archive by using the --delete option. Specify the name of the archive with --file=archive-name (-f archive-name) and then specify the names of the members to be deleted; if you list no member names, nothing will be deleted. The --verbose (-v) option will cause tar to print the names of the members as they are deleted. As with --extract (--get, -x), 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 section 9. Tapes and Other Archive 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
$

@quote-arg {I changed the order of these nodes around and haven't had a chance to fix the above example's results, yet. I have to play with this and follow it and see what it actually does!}

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


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003  

Please take a moment to fill out this visitor survey
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)