Created
February 16, 2016 20:48
-
-
Save bltavares/42a192cccdd2d344ed83 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 -x | |
help() { | |
echo "Usage: cleanup.sh 'path/to/a.zip' 'Name' 'Replacement'" | |
} | |
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then | |
help | |
exit 1 | |
fi | |
file="$1" | |
name="$2" | |
replacement="$3" | |
tmp_dir="$(mktemp -d)" | |
unzip -qq "$file" -d "$tmp_dir" | |
( | |
cd "$tmp_dir" | |
find . -exec sed -i '' "s#$name#$replacement#" {} 2>/dev/null \; | |
) | |
tar czf output.tar.gz -C "$tmp_dir" . | |
echo "Content is now on output.tar.gz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment