Create a tar.xz file on command line - windows

How can I compress a tar file into a tar.xz file on Windows?
I converted my folder into a tar file as follows:
Selected the file
Right-clicked one of the highlighted items
Clicked add to archive
Choose tar from the archive format drop-down menu

tar is now available natively on Windows 10, just open cmd.exe and you can create a tar.xz file with tar -cJf <archive.tar.xz> <files>

You can do thease ones
- Download 7zip then pack and unpack zip file
https://www.7-zip.org/
- Download Linux subsystem for Windows (MSYS,Cygwin, Virtual Machines)
https://learn.microsoft.com/en-us/windows/wsl/install-win10#enable-the-windows-subsystem-for-linux-feature-gui
http://www.cygwin.com/
http://www.mingw.org/wiki/msys

Related

How to run a .sh script to create a *.zip file?

I try to write a shell script create_zip.sh to zip my desired folders as a .zip file.
The content of create_zip.sh is as following:
CODE_DIR='exercise_code/'
EXERCISE_ZIP_NAME='exercise_01.zip'
EXERCISE_DIR=$(pwd)
echo 'Zipping file '$EXERCISE_ZIP_NAME
zip -r $EXERCISE_ZIP_NAME $CODE_DIR
echo $EXERCISE_ZIP_NAME ' created successfully!!! '
But when I double-clicked on the file create_zip.sh, it just opened the Git Bash window and closed immediately. Then nothing happened! (No output message, no newly created *.zip)
How can I solve it? I am using Win10 and with Git Bash as default application to open *.sh file.
Any solution will be very appreciated.
You probably don't have zip installed in Git Bash.
Try the following steps:
Navigate to https://sourceforge.net/projects/gnuwin32/files/zip/3.0/
Download zip-3.0-bin.zip
In the zipped file, in the bin folder, find
the file zip.exe
Extract the file "zip.exe" to your "mingw64" bin
folder (for me: C:\Program Files\Git\mingw64\bin)
Navigate to https://sourceforge.net/projects/gnuwin32/files/bzip2/1.0.5/
Download bzip2-1.0.5-bin.zip
In the zipped file, in the bin folder, find the file bzip2.dll
Extract bzip2.dll to your "mingw64" bin folder (same folder - C:\Program Files\Git\mingw64\bin)

How to open an old .exe file to view it's (text) contents?

Look at this page: http://www.cde.ca.gov/ds/sd/sd/filesgrad.asp
Newer files are text files but older ones executables. How should one open them or do anything with them?
The exe files are self-extracting zip files.
You can open them with winrar, winzip, 7z, and others, such as command line unzip that you can get on most platforms.
$ unzip -t grad93.exe
Archive: grad93.exe
testing: GRAD93.DBF OK
No errors detected in compressed data of grad93.exe.

Zip folder created by shell script not opening

I am using the below script to zip the folder and it contents :-
cd /home/fs/Inbnd/
pwd
tar -cvf Image_test_new.zip Image
chmod 777 *
chown fusionc:staff *
The file image.zip is getting created successfully. But the file is not opening and showing an error :
Is there an error in the ststement I am using to zip?
tar -cvf makes a tar ball, not a zip archive. You can verify this in Linux, before trying to open it in Windows.
touch not_going_to_be_a_zip
tar -cvf not_really_a.zip not_going_to_be_a_zip
unzip not_really_a.zip
Archive: not_really_a.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of not_really_a.zip or
not_really_a.zip.zip, and cannot find not_really_a.zip.ZIP, period.
The zip utility does a good job at making zip archives.
touch will_be_a_zip
zip i_am_a.zip will_be_a_zip Archive: i_am_a.zip
testing: will_be_a_zip OK
No errors detected in compressed data of i_am_a.zip.
unzip -t i_am_a.zip
Archive: i_am_a.zip
testing: will_be_a_zip OK
No errors detected in compressed data of i_am_a.zip.
Note: unzip -t will test the archive only, make sure its okay before trying it in Windows.
If you cannot use the standard approach like zip/unzip and if you have JDK installed on your machine then you can use the jar utility from JDK's bin folder.
To zip a file
jar cvf zip_file_name.zip image.jpg
The only overhead is that it will add a META-INF folder with a file named MANIFEST.MF in it, which you can delete after extracting the zip file.
Try to use zip command instead of tar command.

How to zip a file using cmd line?

I want to zip a directory using the batch file command (Windows XP batch file).
For example, if I want to unzip a file means I can use the jar -xf file.zip(java) bat file command.
Like that I want a command line batch to zip a directory.
If you are using Ubuntu Linux:
Install zip
sudo apt-get install zip
Zip your folder:
zip -r {filename.zip} {foldername}
If you are using Microsoft Windows:
Windows does not come with a command-line zip program, despite Windows Explorer natively supporting Zip files since the Plus! pack for Windows 98.
I recommend the open-source 7-Zip utility which includes a command-line executable and supports many different archive file types, especially its own *.7z format which offers superior compression ratios to traditional (PKZIP) *.zip files:
Download 7-Zip from the 7-Zip home page
Add the path to 7z.exe to your PATH environment variable. See this QA:
How to set the path and environment variables in Windows
Open a new command-prompt window and use this command to create a PKZIP *.zip file:
7z a -tzip {yourfile.zip} {yourfolder}
Cross-platform Java:
If you have the Java JDK installed then you can use the jar utility to create Zip files, as *.jar files are essentially just renamed *.zip (PKZIP) files:
jar -cfM {yourfile.zip} {yourfolder}
Explanation:
* -c compress
* -f specify filename
* -M do not include a MANIFEST file
Yes, we can zip and unzip the file/folder using cmd. See the below command and simply you can copy past in cmd and change the directory and file name
To Zip/Compress File
powershell Compress-Archive D:\Build\FolderName D:\Build\FolderName.zip
To Unzip/Expand File
powershell expand-archive D:\Build\FileName.zip D:\deployments\FileName
You can use the following command:
zip -r nameoffile.zip directory
Hope this helps.
Windows 10 has tar command since 2018. It supports zip archive in default. You do not need to install any additional packages nor software.
tar.exe acvf yourfile.zip yourfolder
Compress-Archive in PowerShell does not support 2GB+ files.
The zip Package should be installed in system.
To Zip a File
zip <filename.zip> <file>
Example:
zip doc.zip doc.txt
To Unzip a File
unzip <filename.zip>
Example:
unzip mydata.zip
Zip the folder from cmd by running PowerShell:
powershell "Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::CreateFromDirectory('folder','archive.zip')"
Unzip:
powershell "Add-Type -A System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory('archive.zip','folder')"
Nothing listed here worked with me. This should be a very simple thing. I post my answer here, if anything because each time I search for "how to zip on the cmd window" I end up on this page, with no solution that works for me.
So here is the one that works with me: zip output_file input_files, as in the screenshot below.

Untar multipart tarball on Windows

I have a series of files named filename.part0.tar, filename.part1.tar, … filename.part8.tar.
I guess tar can create multiple volumes when archiving, but I can't seem to find a way to unarchive them on Windows. I've tried to untar them using 7zip (GUI & commandline), WinRAR, tar114 (which doesn't run on 64-bit Windows), WinZip, and ZenTar (a little utility I found).
All programs run through the part0 file, extracting 3 rar files, then quit reporting an error. None of the other part files are recognized as .tar, .rar, .zip, or .gz.
I've tried concatenating them using the DOS copy command, but that doesn't work, possibly because part0 thru part6 and part8 are each 100Mb, while part7 is 53Mb and therefore likely the last part. I've tried several different logical orders for the files in concatenation, but no joy.
Other than installing Linux, finding a live distro, or tracking down the guy who left these files for me, how can I untar these files?
Install 7-zip. Right click on the first tar. In the context menu, go to "7zip -> Extract Here".
Works like a charm, no command-line kung-fu needed:)
EDIT:
I only now noticed that you mention already having tried 7zip. It might have balked if you tried to "open" the tar by going "open with" -> 7zip - Their command-line for opening files is a little unorthodox, so you have to associate via 7zip instead of via the file association system built-in to windows. If you try the right click -> "7-zip" -> "extract here", though, that should work- I tested the solution myself (albeit on a 32-bit Windows box- Don't have a 64 available)
1) download gzip http://www.gzip.org/ for windows and unpack it
2) gzip -c filename.part0.tar > foo.gz
gzip -c filename.part1.tar >> foo.gz
...
gzip -c filename.part8.tar >> foo.gz
3) unpack foo.gz
worked for me
As above, I had the same issue and ran into this old thread. For me it was a severe case of RTFM when installing a Siebel VM . These instructions were straight from the manual:
cat \
OVM_EL5U3_X86_ORACLE11G_SIEBEL811ENU_SIA21111_PVM.tgz.1of3 \
OVM_EL5U3_X86_ORACLE11G_SIEBEL811ENU_SIA21111_PVM.tgz.2of3 \
OVM_EL5U3_X86_ORACLE11G_SIEBEL811ENU_SIA21111_PVM.tgz.3of3 \
| tar xzf –
Worked for me!
The tar -M switch should it for you on windows (I'm using tar.exe).
tar --help says:
-M, --multi-volume create/list/extract multi-volume archive
I found this thread because I had the same problem with these files. Yes, the same exact files you have. Here's the correct order: 042358617 (i.e. start with part0, then part4, etc.)
Concatenate in that order and you'll get a tarball you can unarchive. (I'm not on Windows, so I can't advise on what app to use.) Note that of the 19 items contained therein, 3 are zip files that some unarchive utilities will report as being corrupted. Other apps will allow you to extract 99% of their contents. Again, I'm not on Windows, so you'll have to experiment for yourself.
Enjoy! ;)
This works well for me with multivolume tar archives (numbered .tar.1, .tar.2 and so on) and even allows to --list or --get specific folders or files in them:
#!/bin/bash
TAR=/usr/bin/tar
ARCHIVE=bkup-01Jun
RPATH=home/user
RDEST=restore/
EXCLUDE=.*
mkdir -p $RDEST
$TAR vf $ARCHIVE.tar.1 -F 'echo '$ARCHIVE'.tar.${TAR_VOLUME} >&${TAR_FD}' -C $RDEST --get $RPATH --exclude "$EXCLUDE"
Copy to a script file, then just change the parameters:
TAR=location of tar binary
ARCHIVE=Archive base name (without .tar.multivolumenumber)
RPATH=path to restore (leave empty for full restore)
RDEST=restore destination folder (relative or absolute path)
EXCLUDE=files to exclude (with pattern matching)
Interesting thing for me is you really DON'T use the -M option, as this would only ask you questions (insert next volume etc.)
Hello perhaps would help.
I had the same problems ...
a save on my web site made automaticaly in Centos at 4 am create multiple file in multivolume tar format (saveblabla.tar, saveblabla.tar1.tar, saveblabla.tar2.tar,etc..)
after downloading this file on my PC (windows) i can't extract them with both windows cmd or 7zip (unknow error).
I thirst binary copy file to reassemble tar files. (above in that thread)
copy /b file1+file2+file3 destination
after that, 7zip worked !!! Thanks for you help

Resources