Sometimes I need to upload log files to a vendor. For some reason large vendors like to add file size limits to their uploads. In a large environment this makes it hard to upload logs.
A way around this is to zip a folder and split it into smaller chunks of a pre defined size.
Lets say a vendor imposes a maximum file upload size of 85MB. we could use the zip command and tell it to create a new file every 85MB with the following:
zip -r -s 85m new-zip-name.zip /tmp/logfiles/*
new-zip-name.zip can be anything you want as long as it ends in .zip. The resulting files will have a number appended to them.
/tmp/logfiles/* is the directory you want to zip up.
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Wednesday, 25 October 2017
How to Tar and Gzip a directory
TAR is short for Tape Archive and is often refereed to as a tarball. Think of it as a Windows zip file without the compression.
GZIP is short for GNU Zip. It is used to compress a single file on the Linux platform.
Together, you can TAR a folder into a single file and then reduce the size of the file with Gzip. This makes it easy to transfer around a network or upload it somewhere else.
1) Navigate to the folder which contains the directory.
2) Run the following command:
tar -zcvf new-archive-name.tar.gz directory_name
new-archive-name.tar.gz can be anything providing it ends in tar.gz
directory_name is the name of the directory you are trying to compress. If I wanted to TAR and Gzip the /tmp/ folder, I would run:
tar -zcvf TempFiles.tar.gz /tmp
GZIP is short for GNU Zip. It is used to compress a single file on the Linux platform.
Together, you can TAR a folder into a single file and then reduce the size of the file with Gzip. This makes it easy to transfer around a network or upload it somewhere else.
1) Navigate to the folder which contains the directory.
2) Run the following command:
tar -zcvf new-archive-name.tar.gz directory_name
new-archive-name.tar.gz can be anything providing it ends in tar.gz
directory_name is the name of the directory you are trying to compress. If I wanted to TAR and Gzip the /tmp/ folder, I would run:
tar -zcvf TempFiles.tar.gz /tmp
Subscribe to:
Posts (Atom)