tar
13 May 2015 • Leave Comments"tar" stands for tape archive. It is an archiving file format.
List archive
~ $ tar -tvf hongkan.tar.xz
Create archive
~ $ tar -cJpvf hongkan.tar.xz hongkan/
- c: create tar file;
-
J: compress the tar file with xz;
Alternatives are: z for gzip, j for bzip2.
- p: extract information about file permissions;
- v: verbosely list files processed;
- f: archive file name.
Encrypt/sign archive
~ $ gpg --recipient you@email.com --sign --encrypt hongkan.tar.xz
~ $ gpg --output hongkan.tar.xz --decrypt hongkan.tar.xz.gpg
Extract archive
~ $ tar -tvf hongkan.tar.xz
~ $ tar -xJpvf hongkan.tar.xz [hongkan/test.md]
Update archive
# edit hongkan/test.md
~ $ unxz hongkan.tar.xz
~ $ tar --delete -vf hongkan.tar hongkan/test.md
~ $ tar -rpvf hongkan.tar hongkan/test.md
~ $ xz hongkan.tar
-
r: append files to the end of an archive.
There is no real way to replace an existing file with the same name. Even the
-u --update
parameter does not help.We must first
--delete
and then-r --append
the file to archive. -
Cannot update compressed archives. Decompress tar first.