Bash script to edit CFBundleVersion field of PROJECT-Info.plist file

Use PlistBuddy:

# cf. http://davedelong.com/blog/2009/04/15/incrementing-build-numbers-xcode
/usr/libexec/PlistBuddy -h
/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" test.plist
myversion=1.0.5
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion '${myversion}'" test.plist

In this specific case you can also use Xcode's agvtool. You do not even need to provide the path to the PROJECT-Info.plist file. Inside your project dir run:

agvtool new-version -all "$BUILD_NUMBER" # sets CFBundleVersion
agvtool new-marketing-version "$BUNDLE_VERSION" # sets CFBundleShortVersionString