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:
OLD_NO=$(grep '_version=' "$FNAME" | awk -F '"' '{print $12}')
Btw: The job can be done with awk
only, you don't need grep:
OLD_NO=$(awk -F '"' '/_version=/ {print $12}' "$FNAME")
Note that awk programs having the following form:
condition { action } [; more of them ]
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=
:
/_version=/ { print $12 }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…