How can I run the "tar -czf" command in Windows?

12

1

I am currently running a computer which has access to only Windows.

I have to submit a folder after running tar -czf on it.

How can I do this in Windows, do I have any options?

user54094

Posted 2011-02-11T18:22:29.383

Reputation: 271

Answers

10

If all you want is to create a tar.gz (also called tgz) file, then you can use 7Zip from http://www.7-zip.org/

To run like "tar -czf" you need to chain two 7z calls:

7z -ttar a dummy c:\my\path\* -so | 7z -si -tgzip a x.tgz

This creates a file x.tgz containing all data from c:\my\path\.

The -so redirects the output to stdout and the -si option picks that data up.

Yacine Filali

Posted 2011-02-11T18:22:29.383

Reputation:

you should have definitely more upvotes – Valerio – 2016-12-29T09:38:53.217

4

Take a look at Tar for Windows.

The GNU Tar program provides the ability to create tar archives, as well as various other kinds of manipulation. For example, you can use tar on previously created archives to extract files, to store additional files, or to update or list files which were already stored.

The Win32 port can only create tar archives, but cannot pipe its output to other programs such as gzip or compress, and will not create tar.gz archives; you will have to use or simulate a batch pipe. BsdTar does have the ability to direcly create and manipulate .tar, .tar.gz, tar.bz2, .zip, .gz and .bz2 archives, understands the most-used options of GNU Tar, and is also much faster; for most purposes it is to be preferred to GNU Tar.

Dani

Posted 2011-02-11T18:22:29.383

Reputation: 713

Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.

– soandos – 2012-07-16T02:38:01.027

2

You want to install Cygwin or MSYS, they usually come with tar utility.

Yasir Arsanukaev

Posted 2011-02-11T18:22:29.383

Reputation: 203

2

tar -czf creates a gzipped tar file, usually the extension .tar.gz or .tgz is used.

Windows has no built-in support for creating (or reading) tar files or gzipped files, and Microsoft offers no tools for this either.

This format can be created using, e.g., 7Zip; see for example this blog post: http://www.tmsnetwork.org/blog/creating-targz-archive-easily-windows (archive.org copy: apparently this blog disappeared). Many more tools could be used, see http://www.7zip.com/type/5/TAR (archive.org copy: apparently 7zip.com disappeared, to be replaced by 7-zip.org).

MarnixKlooster ReinstateMonica

Posted 2011-02-11T18:22:29.383

Reputation: 360

1I think he is asking for a native way to do it. (instead of 3rd party) – Pacerier – 2014-04-24T11:56:53.190

1

You can also download and install 7zip. http://www.7zip.org. With it, you can both unpack and pack many different compression types including gzip.

Eli

Posted 2011-02-11T18:22:29.383

Reputation: 111

0

I think the most elegant way to do it would be to install Linux subsystem for Windows.

https://msdn.microsoft.com/en-us/commandline/wsl/install_guide#enable-the-windows-subsystem-for-linux-feature-gui

Please keep in mind that this is beta.

There are also lots of ways to get Linux functionality:

  • MSYS
  • Cygwin
  • Virtual Machines

There are lots of tools and applications that do this.

Martin Lunn

Posted 2011-02-11T18:22:29.383

Reputation: 1

0

Make these steps:

hubaishan

Posted 2011-02-11T18:22:29.383

Reputation: 1