Are Tar.Gz and Tgz the Same Thing

Are tar.gz and tgz the same thing?

I think in the old package repo days, .tgz was used because files on DOS floppies could only have three letter extensions. When this limitation was removed, .tar.gz was used to be more verbose by showing both the archive type (tar) and zipper (gzip).

They are identical.

.tar vs .tgz...what is the difference?

Absolutely no difference. A filename is just a filename. Usually, when you use the tgz form, it's to indicate that you've gzipped the tar file (either as a second step or using the z flag):

tar zcvf filename.tgz {filenames}

or

tar cvf filename {filenames}
gzip -S .tgz filename

.tar, on the other hand, normally means "this is an uncompressed tar file":

tar cvf filename.tar {filenames}

Most modern tar implementations also support the j flag to use bzip2 compression, so you might also use:

tar jcvf filename.tar.bz2 {filenames}

Difference between two .tar.gz file lists on linux

Just list the contents and do diff:

diff <(tar -tvf 1.tar.gz | sort) <(tar -tvf 2.tar.gz | sort)

What is a difference between zip and tgz format?

They are different archive formats. They are used because it saves bandwidth and because they bundle files.

Zip is more common on Windows and there is a decompressor preinstalled.

Tgz is gzip + tar and is common on Linux. There is also a decompressor preinstalled, most of the time. Also known as .tar.gz.

If you're on Windows I'd download the zip or the installer, as you don't have to install a third party program to open it. If you're on Linux I recommend installing scala through your package manager.

Why do the md5 hashes of two tarballs of the same file differ?

tar czf outfile infiles is equivalent to

tar cf - infiles | gzip > outfile

The reason the files are different is because gzip puts its input filename and modification time into the compressed file. When the input is a pipe, it uses an empty string as the filename and the current time as the modification time.

But it also has a --no-name option, which tells it not to put the name and timestamp into the file. So if you write the expanded command explicitly, instead of using the -z option to tar, you can make use of this option.

tar cf - testfile | gzip --no-name > a.tar.gz
tar cf - testfile | gzip --no-name > b.tar.gz

I tested this on OS X 10.6.8 and it works.

Rename tgz to tar.gz while using sbt-native-packager

To make sure I got your question right:

$ sbt universal:packageZipTarball

produces a file with the extension .tgz. What you want is a file with the extension .tar.gz.

You can achieve this by overrding the universal:packageZipTarball and simply move the result. I haven't tested this code, but it should give you a rough idea

packageZipTarball in Universal := {
val targzFile = universal:packageZipTarball
val renamedFile = targzFile.getParent / targzFile.getName.replaceAll("\\.tgz$", ".tar.gz")
IO.move(targzFile, renamedFile)
renamedFile
}

Cheers,
Muki

Change file extension from .tar.gz to .tgz in Python3

is using path lib a requirement?

if not, the os module would work just fine:

import os

path_location = "/path/to/folder"
filename = "filename.extension"

newname = '.'.join([filename.split('.')[0], 'tgz'])

os.rename(os.path.join(path_location, filename), os.path.join(path_location, newname))

EDIT:

found this on the pathlib docs:

PurePath.with_suffix(suffix)¶

Return a new path with the suffix changed. If the original path doesn’t have a suffix, the new suffix is appended instead. If the suffix is an empty string, the original suffix is removed:

>>>
>>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')
>>> p.with_suffix('.bz2')
PureWindowsPath('c:/Downloads/pathlib.tar.bz2')
>>> p = PureWindowsPath('README')
>>> p.with_suffix('.txt')
PureWindowsPath('README.txt')
>>> p = PureWindowsPath('README.txt')
>>> p.with_suffix('')
PureWindowsPath('README')

EDIT 2:

from pathlib import Path
p = Path('path/to/tar.gz')
new_ext = "tgz"
filename = p.stem
p.rename(Path(p.parent, "{0}.{1}".format(filename, new_ext)))

How do I decompress a hosted tar file on the fly using NodeJS

tgz is not tar. It's a gzipped tar-ball.

From https://www.npmjs.com/package/tar-stream:

Note that you still need to gunzip your data if you have a .tar.gz. We recommend using gunzip-maybe in conjunction with this.

Nested tar is created while creating simple tar.gz in python

You don't have a nested tar file. You have a tar file inside gz file.

Your code works correctly.

gz is its own format. It is like zip, but can hold only one single file.
tar is an uncompressed archive format. It has no compression of its own.

So, whenever you see a file of type tar.gz or tar.bz or tar.xz - you are seeing a combination of two tools - a tar archiver and a compressor of some kind.

What ever app you are using to open your file obviously isn't designed specifically to work with compressed tar files, so it displays your file as an archive with a nested tar, which is technically true, but most modern utilities avoid showing it like this.



Related Topics



Leave a reply



Submit