Greetings, jungle-dwellers! If big files have been driving you bananas, it’s time to zip them up. In this guide, we’ll navigate the wilds of the command line on macOS and Linux, showing you how to zip files as easily as a monkey swings from tree to tree. So, grab your bananas, and let’s get zipping!
Table of contents
- Method 1: Zip Files on macOS/Linux Using Command Line
- Method 2: Zip Files with More Compression
- Method 3: Zip a Folder Recursively
- Method 4: Add More Files to an Existing Zip
- Method 5: Zip Files Without Compression
- Method 6: How To Create a Password-Protected Zip File
- Method 7: Create Split Zip Files
- Method 8: Update Files in a Zip Archive
- Method 9: Delete Files from a Zip Archive
How To Zip Files on macOS/Linux Using Command Line
The command line may seem as dense as a rainforest, but don’t worry, we’re here to guide you through. Here’s how to zip files on macOS and Linux:
-
Open Terminal on Directory: Open up your file manager and find the directory where your zip archive is located. Click the three dots and click on (Open in terminal). It’s like the tree where all the magic happens.
-
Zip the file: Use the ‘zip’ command followed by the name you want for your zipped file and the name of your file. It’s like squashing a bunch of bananas into a handy, portable snack. Here’s an example:
zip MyFile.zip MyFile.txt
How To Zip Files with More Compression
If you’re dealing with a particularly large file, or you just want to save as much space as possible, you can use the ‘-9’ option to apply the maximum compression level:
-
Use the ‘-9’ option: After the ‘zip’ command, add ‘-9’ followed by the name you want for your zipped file and the name of your file. For example, type in terminal:
zip -9 MyCompressedFile.zip MyLargeFile.txt
How To Zip a Folder Recursively
If you want to zip an entire folder, including all its subfolders and files, you can use the ‘-r’ option:
-
Use the ‘-r’ option: After the ‘zip’ command, add ‘-r’ followed by the name you want for your zipped file and the name of your folder.
zip -r MyFolder.zip MyFolder
Check out our guide on zipping folders recursively for more information.
How To Add More Files to an Existing Zip
If you’ve already created a zip file but want to add more files to it, you can use the ‘-u’ option:
-
Use the ‘-u’ option: After the ‘zip’ command, add ‘-u’ followed by the name of your existing zipped file and the name of the file you want to add.
zip -u MyExistingFile.zip MyAdditionalFile.txt
With these tips, you’ll be zipping files like a pro. So, keep your chin up, your tail curled, and your files zipped. Happy archiving!
How To Zip Files Without Compression
If you want to zip files without compressing them, you can use the ‘-0’ (zero) option:
-
Use the ‘-0’ option: After the ‘zip’ command, add ‘-0’ followed by the name you want for your zipped file and the name of your file.
zip -0 MyFile.zip MyFile.txt
This command will store the files without compression.
How To Create a Password-Protected Zip File Without Being Prompted
If you want to protect your zip file with a password without being prompted, you can use the ‘-P’ option:
-
Use the ‘-P’ option: After the ‘zip’ command, add ‘-P’ followed by your password, and then the name you want for your zipped file and the name of your file.
zip -P YourPassword MySecureFile.zip MyFile.txt
This command will create a password-protected zip file using the password ‘YourPassword’. Remember, just like a monkey hides its bananas, keep your password safe!
How To Create Split Zip Files
If you want to create a new zip file split into smaller parts, you can use the ‘-s’ option followed by the size of each part:
-
Use the ‘-s’ option: After the ‘zip’ command, add ‘-s’ followed by the size of each part and the name you want for your zipped file and the name of your file.
zip -s 10m MySplitFile.zip MyLargeFile.mp4
This command will create a multi-part zip file, each part being 10MB.
How To Update Files in a Zip Archive
If you want to update files in a zip archive, you can use the ‘-f’ option.
-
Use the ‘-f’ option: After the ‘zip’ command, add ‘-f’ followed by the name of your existing zipped file.
The -f option in the zip command is used for “freshening” an existing zip archive.
“Freshening” means that zip will update (replace) files in the archive only if the source file has been modified more recently than the version already in the zip archive. Files in the source file list not already in the zip archive are ignored.
Here’s an example of how to use it:
zip -f existing_archive.zip
In this command, existing_archive.zip is the name of the zip file you want to freshen. This command will go through the files in existing_archive.zip and update them if the corresponding file in the current directory is newer.
Please note that the -f option will not add files to the zip archive that weren’t there in the first place. If you want to both update existing files and add new ones, you should use the -u (update) option instead.
This command will refresh the specified files in the zip archive.
How To Delete Files from a Zip Archive
If you want to delete files from a zip archive, you can use the ‘-d’ option:
-
Use the ‘-d’ option: After the ‘zip’ command, add ‘-d’ followed by the name of your existing zipped file and the name of the file you want to delete. Here’s an example:
zip -d MyExistingFile.zip MyExistingFile/FileToDelete.webp
This command will delete the specified file from the zip archive.
Remember, the command line might seem like a jungle, but with these tips, you’ll be zipping files with the best of them. So, keep your wits about you, your tail swinging, and your files neatly zipped. Happy archiving!