<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1046278168754291&amp;ev=PageView&amp;noscript=1">
Blog

Tuesday, 17 February 2009 09:30

Delete files or directories from a tar or zip file

Written by Louise Fahys
Be the first to comment!

The --delete option allows specified files to be completely removed from a tar file (except when the tar file is on magnetic tape). However, this is different from an extraction, as copies of the removed files are not made and placed in the current directory. Thus, for example, the files file1 and file2 can be removed from file.tar with the following:

tar -f file.tar --delete file1 file2

To remove a directory dir1:

tar -f file.tar --delete dir1/*

The -t option tells tar to list the contents of an uncompressed archive without performing an extraction. Thus, the following would list the contents of file.tar:

tar -tf file.tar

Tagged under Development, Linux

Louise Fahys

Louise Fahys

"My passion is to take ideas and build them into software solutions that help people." Louise has over 20 years of business and technical experience including project management, website design, architecture and implementation. Louise has helped start and run several interactive sites for sports organizations and businesses.

Subscribe to Email Updates