i have file following contents
filename:versioninfo.properties
installed version:13.7.0-2 previous version:13.6.0-12
filename: main.sh
#!/bin/ksh new_maj_version=$1 # sample content: 13.7.0 new_min_version=$2 # sample content: 4
every time run main.sh want edit versioninfo.properties file. installed version should shift previous version , new_maj_version , new_min_version placed in installed version. how can achieve it?
sample output after running main.sh
filename:versioninfo.properties
installed version:13.7.0-4 previous version:13.7.0-2
try this: (save main.sh):
#!/bin/ksh awk -f: -v a="$1" -v i="$2" 'nr==1{n=$2;print $1":"a"-"i;next}{print $1":"n}' /versioninfo.properties > /tmp/tmpversion && mv /tmp/tmpversion versioninfo.properties
try with
main.sh "13.7.0" "4"
Comments
Post a Comment