在写入变量之前定义变量

时间:2013-11-27 19:25:47

标签: bash

目前,我有;

echo "Whats the year?"
read year
echo "Whats the Month you're running this for?"
read month

TARGET=`pwd`/"BLAH"$year$month"BLAH"
TARGET_888=`pwd`/"BLAH"$year$month"BLAH"

输出结果为:pwd / BLAH201312BLAH例如。有什么方法可以使用变量,所以在此之前不使用echo的定义TARGET和TARGET_888?我只是想让我的代码更整洁,而不是在我的代码中间有变量。

1 个答案:

答案 0 :(得分:1)

您可以使用read -p

来避免回声
read -p "Whats the year?" year
read -p "Whats the Month you're running this for?" month

TARGET="$PWD/BLAH${year}${month}BLAH"
TARGET_888="$TAGET"
相关问题