Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native .tar extraction in Powershell

Tags:

powershell

tar

I have a .tar.gz file that I need to extract. I've handled the gunzip bit with the GzipStream object from System.IO.Compression, but I couldn't find anything for dealing with tarballs in that namespace. Is there a way to deal with .tar files natively in Powershell? Note that it's only important that I be able to call any such function/method/object construction/system binary from a Powershell script; it doesn't need to actually be written in powershell. (If it matters I'm using 64-bit windows 10)

P.S. please don't say "use 7zip"; that's not native

like image 554
bfieck Avatar asked Aug 04 '16 19:08

bfieck


People also ask

How do I extract a tar file in PowerShell?

In Windows 10, you can install 7zip support from within PowerShell directly with Install-Package 7Zip4Powershell . The Expand-7zip cmdlet will extract multiple archive formats, including tar.

How do I extract data from a tar file?

Simply right-click the item you want to compress, mouseover compress, and choose tar. gz. You can also right-click a tar. gz file, mouseover extract, and select an option to unpack the archive.

Can we extract tar file in Windows?

Since TAR files are simply archives, they need to be compressed by another utility, such as gzip, to reduce their size. The TAR format is often used for open source software distribution. Tar unzip software like WinZip is needed to unpack a tar file.


1 Answers

I believe tar has been added as a native function in Windows 10 since the posting of this.

From the command prompt or PowerShell in Windows 10 I can run

tar -xvzf .\whatever.tar.gz 

Note that the .\ was added after auto-completing by the use of tab in PowerShell, but I think it should work without that.

There may be some underlying differences between this function and its Unix implementation (since it is on Windows after all), but it worked for me.

like image 129
Broper Avatar answered Oct 23 '22 02:10

Broper