我对Unix Bash脚本编写比较新,想知道这是否可行。我想要多次询问用户的输入值,然后将这些输入值存储到一个变量中。
userinputs= #nothing at the start
read string
<code to add $string to $userinputs>
read string
<code to add $string to $userinputs> #this should add this input along with the other input
如果用户第一次输入"abc",则将其添加到$userinputs中。
然后再次要求输入时,如果用户输入"123",脚本应该将其存储在同一个$userinputs中。
这将使$userinput=abc123。