BASH:我如何使用参数“read”两次?

时间:2013-12-04 07:09:59

标签: database bash

我想用这个脚本编写foo.sh中的read:

b=1
c=1
y=1
echo "What is the name for the $((b++)) database ?"
read name$((c++))

echo $name$((y++)) >> foo.sh

我希望在foo.sh中代表:

Name1
Name2
Name3

但只有

1
2
3

任何想法?

1 个答案:

答案 0 :(得分:1)

您必须将read <var>放在单独的一行。您也不需要其中一个变量。试试这个 -

b=1
c=1
echo "What is the name for the $((b++)) database ?"
read name
name=$name$((c++))
echo $name >> foo.sh