Reputation: 209
I have a text file called VERSION.txt with only one line of content:
2.0.5
I'd like to use a shell script to read that version number and assign it to a env variable like so:
export APP_VERSION='2.0.5'
This is about as close as I could come.
input="VERSION.txt"
while IFS= read -r line
do
export APP_VERSION=$line
echo 'App version is' ${APP_VERSION}
done < "$input"
Which seems to work, but when I echo $APP_VERSION
I get a blank result.
Any tips?
Upvotes: 1
Views: 1336
Reputation: 1
You can do something like this:
#!/bin/bash
while read -r arg_1; do
<your command with each arg in your text file using ${arg_1}>
done < ./<your inputs separated line by line text file>
Upvotes: 0
Reputation: 88553
input="VERSION.txt"
export APP_VERSION=$(cat "$input")
echo "App version is ${APP_VERSION}"
Upvotes: 4