Write a Linux shell script to zip entire folder.
This is a small script which will zip a folder to any zipping algorithms such as zip, gz, bz2 etc.
#!/bin/bash
read -p “please enter the folder location: ” SFOLD1
read -p “Target location to save this zip file: ” DFOLD1
read -p “Select compress type(zip, tar.gz, tar.bz2): ” COMP1
case $COMP1 in
zip)zip ${DFOLD1}/file1.zip $SFOLD1;;
tar.gz) tar cvfz ${DFOLD1}/file1.tar.gz $SFOLD1;;
tar.bz2) tar cvfj ${DFOLD1}/file1.tar.bz2 $SFOLD1;;
*) echo “Please enter a valid compression(zip, tar.gz, tar.bz2)”;exit;;
esac
Let me explain what this script will do. This script will ask for source folder which you want to compress, destination folder where you want to create this compressed folder and the type of compress.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018