bash-3.2$ FNAME=$1
bash-3.2$ OLD_NO=$(grep "_version=" | awk -F '"' '{print $12}' $FNAME)
Line 2 does not appear to be working for me. Am I not closing/quoting it correctly? It seems to hang
Updated the script to reflect below suggestions
echo $OLD_NO
OLD_NO=$(grep '_version=' "$FNAME" | awk -F '"' '{print $12}')
#Get the version of the
echo "What do you want to update release number to?"
REPLACEMENT="_version="$NEW_NO
echo $REPLACEMENT
sed -i ''s/$OLD_NO/$REPLACEMENT/g'' $FNAME
~
get a new error
bash-3.2$ ./vu reader.xml
What do you want to update release number to?
_version=
sed: -e expression #1, char 0: no previous regular expression
Works in bash though
bash-3.2$ grep _version market_rules_cd.reader.xml | awk -F '"' '{print $12}'
14.8.21.1
The line hangs because
grep '_version='
will blocking wait on stdin since you didn't passed a file name argument. To stop it from hanging pass the file name to grep, not to awk. awk will then process grep's output:Btw: The job can be done with
awk
only, you don't need grep:Note that awk programs having the following form:
You can omit the condition if the action should apply to every line (this is widely used), however in this case you can use a regex condition to restrict the action only to lines containing
_version=
: