What bash basic have I forgotten? I'm just trying to build a filename up in a script with VERSION and BUILD info...
So, dead-easy if hardcoded - this all makes sense:
VERSION=1.0.1
BUILD=45
NAME=Product-$VERSION-$BUILD.zip
echo $NAME
> Product-1.0.1-45.zip
But, what if the VERSION is provided via a (single) line in a file with contents just "1.0.1":
VERSION=$(<version.txt)
echo $VERSION
> 1.0.1
BUILD=45
NAME=Product-$VERSION-$BUILD.zip
echo $NAME
> -45.zip-1.0.1
?????? "-45.zip-1.0.1"?
Ok, I though it might be some left over newline or end of file character, so I've tried:
VERSION=$(cat version.txt)
VERSION=$(cat version.txt | tr -d '\n')
VERSION=$(sed -n '1p' version.txt)
Same effect. Using quotes around NAME="..."
no joy (I had thought there was some interpolation going on...)
And, this is all on a Mac with:
bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.
Thank you.