Skip to content

Instantly share code, notes, and snippets.

@daniel-abramov
Created September 15, 2017 15:50
Show Gist options
  • Save daniel-abramov/662b9791012f2dc25aae13021f3839b8 to your computer and use it in GitHub Desktop.
Save daniel-abramov/662b9791012f2dc25aae13021f3839b8 to your computer and use it in GitHub Desktop.
Search and replace the version number based on input parameters to the shell script
#!/bin/sh
# This script will update the specified version for all brands to
# X.Y.Z, where X, Y and Z are input parameters specified by the user.
# Example: `$ sh change_version.sh 1.0.0 2.1.0`
if [ $# -lt 2 ]; then
echo "2 arguments are expected"
exit 1
fi
IFS=. read prevX prevY prevZ <<< $1
IFS=. read newX newY newZ <<< $2
find . -type f -exec sed -i "s@$prevX\([\.,_]\)$prevY\1$prevZ@$newX\1$newY\1$newZ@g" {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment