How to Convert Zip to Tar.gz in Ubuntu Linux
This guide provides a direct solution for converting zip archives into tar.gz format on Ubuntu. It explains that no single command exists for this task and outlines the necessary two-step process using standard command-line tools. Readers will learn the exact syntax for extracting zip files and compressing them into the target archive format.
There is no single command that directly converts a zip archive to a
tar.gz archive in Ubuntu. You must use a combination of the
unzip and tar utilities to achieve this
result. The process involves extracting the contents of the zip file and
then immediately recompressing them into the new format.
Begin by opening your terminal and navigating to the directory containing your zip file. Extract the contents using the following command:
unzip archive.zipOnce the files are extracted, create the tar.gz archive by running
the tar command with the gzip compression flag. Replace
folder_name with the actual name of the extracted
directory:
tar -czvf archive.tar.gz folder_name/You can combine these steps into a single line if you prefer to stream the data without saving the extracted files to your disk. Use this command to pipe the output of unzip directly into tar:
unzip -p archive.zip | tar -czvf archive.tar.gz -After conversion, verify the integrity of the new archive by listing
its contents with tar -tzvf archive.tar.gz. You may then
safely delete the original zip file and any temporary extracted
folders.