Skip to content

Instantly share code, notes, and snippets.

@bltavares
Created February 16, 2016 20:48
Show Gist options
  • Save bltavares/42a192cccdd2d344ed83 to your computer and use it in GitHub Desktop.
Save bltavares/42a192cccdd2d344ed83 to your computer and use it in GitHub Desktop.
#!/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