Hi
I have a tar file which include extra files that I don't want. How can I remove these files from my tar file?
Eg:
$tar -tvf ds_autoload.tar
-rwxr-xr-x 224 203 24434 Dec 03 20:29:04 2009 bin/load_ds
-rwxr-xr-x 224 203 1105 Dec 03 18:41:20 2009 /sit/dsrv1/hk/etc/DS_HDR/IMEX_TLS/IMEX_PDLCO.hdr
-rwxr-xr-x 224 203 1105 Dec 03 18:44:50 2009 /sit/dsrv1/hk/etc/DS_HDR/IMEX_TLS/IMEX_PDLCH.hdr
-rwxr-xr-x 224 203 1107 Dec 03 18:46:02 2009 /sit/dsrv1/hk/etc/DS_HDR/IMEX_TLS/TLS_LIMITS.hdr
i want to remove the first file bin/load_ds from the tar. can you help
Scott
December 3, 2009, 8:12am
2
Not sure it's possible on most tars, but GNU tar has a --delete option.
tar -f ds_autoload.tar --delete bin/load_ds
Failing that, extract the file to somewhere, remove the file and then tar it up again. It's also not always a great idea to tar things up with absolute paths.
Hi it is not working fine. i am using ksh shell. please any one help on this;)
tar -f ds_autoload.tar --delete bin/load_ds
tar: Not a recognized flag: -
Usage: tar -{c|r|t|u|x} [-BdFhilmopsvw]
[-Number] [-fFile]
[-bBlocks] [-S [Feet] [Feet @Density ] [Blocksb]]
[-LInputList] [-NBlocks] [-C Directory] File ...
there is no way you can delete a file from tar file
but you can include those file in a exclude list so that those won't get tarred or untarred..
tar -xvf file.tar -X excludelist
even midnight commander does not allows to delete a file from the tar.