Created
July 17, 2023 07:45
-
-
Save naranyala/3ddd46a425d4cc26dfaf0a6f031a5fb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
tar -czf "$directory_name.tar.gz" "$directory" | |
echo "Compression complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment