Created
September 15, 2017 15:50
-
-
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
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/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