我有一个名为 VERSION.txt 的文本文件,其中只有一行内容:
2.0.5
我想使用 shell 脚本来读取该版本号并将其分配给环境变量,如下所示:
export APP_VERSION='2.0.5'
这已经是我所能达到的最接近的结果了。
input="VERSION.txt"
while IFS= read -r line
do
export APP_VERSION=$line
echo 'App version is' ${APP_VERSION}
done < "$input"
这似乎有效,但是当我
echo $APP_VERSION
时,我得到了空白结果。
有什么建议吗?
input="VERSION.txt"
export APP_VERSION=$(cat "$input")
echo "App version is ${APP_VERSION}"
你可以这样做:
#!/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>