简体   繁体   中英

BASH: How can i use “read” with parameters two times?

I wanted to write the read in foo.sh with this script:

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

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

I want that in foo.sh stands:

Name1
Name2
Name3

BUT there only stands

1
2
3

any ideas ?

You have to put read <var> on a separate line. Also one of your variable is not needed. Try this -

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM