Skip to content

Instantly share code, notes, and snippets.

@naranyala
Last active August 8, 2023 03:11
Show Gist options
  • Save naranyala/088ce2ded4390cc418475fa4d3800398 to your computer and use it in GitHub Desktop.
Save naranyala/088ce2ded4390cc418475fa4d3800398 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Verify if the directory argument is provided
if [ -z "$1" ]; then
echo "Please provide the path to the directory you want to compress as the first argument."
exit 1
fi
# Verify if the directory exists
directory="$1"
if [ ! -d "$directory" ]; then
echo "Directory not found!"
exit 1
fi
# Get the directory name
directory_name=$(basename "$directory")
# Compress the directory using rar
rar a "$directory_name.rar" "$directory"
echo "Compression complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment