If you want to zip a file or a directory while being on a Bash Shell on Terminal, you can make use of the zip command.
Before taking a look at how to use this command, make sure that the zip package is available on your OS - Ubuntu/macOS/Linux. It is common that it is not available if you use an image on Docker Container.
# zip bash: zip: command not found
Installing zip package:
# apt install zip .... Preparing to unpack .../unzip_6.0-26ubuntu3.1_arm64.deb ... Unpacking unzip (6.0-26ubuntu3.1) ... Selecting previously unselected package zip. Preparing to unpack .../zip_3.0-12build2_arm64.deb ... Unpacking zip (3.0-12build2) ... Setting up unzip (6.0-26ubuntu3.1) ... Setting up zip (3.0-12build2) ...
Now let's try to zip a file.
# zip data.zip data.txt adding: data.txt (deflated 13%)
Now let's try to zip a directory. Make sure to add -r flag to zip files within the directory recursively.
# zip -r all_reports.zip reports/ updating: reports/ (stored 0%) adding: reports/report_2023.csv (deflated 36%) adding: reports/report_2022.csv (deflated 54%) adding: reports/report_2021.csv (deflated 55%)
Facing issues? Have Questions? Post them here! I am happy to answer!
- Bash Hello World! Script Tutorial
- How to run bash command in background
- How to create new user account in Windows bash
- How to Compare Strings in Bash
- Bash: Allow Command to Fail without exiting Script
- Fix bash: script.sh: Permission denied Error
- Bash getopts Command Example
- How to fix bash ping command not found error
- How to add NewLine Character in Bash Script String
- How to Echo Bash Command to a File
- Bash Command to Find String in a File
- How to open new Terminal using Bash Command
- Bash How to Save Output of a Command to a Variable
- Download a SSL Certificate from a URL in Terminal
- Bash Command to Check IP Address
- Know Bash shell version command
- Bash Command To Check If File Exists
- How to run a Command in Bash Script
- How to Compare two Files in Bash Shell
- How to check if a variable is set in Bash Script or Not
- Convert String from uppercase to lowercase in Bash
- How to see Created Accessed Modified and Changed dates of a file using bash terminal command
- Bash Command To Get Current Time
- Bash command to List Files
- Fix: bash: syntax error near unexpected token
- [Fix] Error 1020 Cloudflare: Access was denied - HowTos
- How to repeat background image in Android Activity - Android
- PHP.ini: How to Remove URL Forward Slash Before Single or Double Quotes - PHP
- Android-Failed to install apk on device EOF Timeout Error - Android
- Add Calendar to SharePoint Site (Office 365) - SharePoint
- Changed AD user display name showing old name in SharePoint - SharePoint
- Maven Unsupported major.minor version 51.0 - Java