Process of reducing the size of one or more files to save storage space
Compress files in different folders without including the parent directories of the path
#!/bin/bashset -euset -o pipefail# Check if a filename argument is providedif [ "$#" -eq 0 ]; then echo "Usage: xyz <filename> <path1> [<path2> ...]" exit 1fifilename=$1# Create a temporary directorymkdir myTempZip# Copy required files to the temporary directoryfor arg in "${@:2}"; do cp -R "$arg" ./myTempZip echo "$arg"done# Navigate to the temporary directorycd myTempZip# Zip the contents of the directoryzip -r "$filename" *# Move the zip file to the parent directorymv "$filename" ../# Navigate back to the original directorycd ..# Remove the temporary directoryrm -rf myTempZip