小编M.A*_*eem的帖子

在 Bash 中将多个用户输入添加到一个变量中

我对 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
Run Code Online (Sandbox Code Playgroud)

因此,如果用户在第一次询问时输入“abc”,则会在 $userinputs 中添加“abc”

然后当再次询问输入并且用户输入“123”时,脚本应将其存储在相同的 $userinputs 中

这将使 $userinput=abc123

unix linux bash

4
推荐指数
1
解决办法
1609
查看次数

标签 统计

bash ×1

linux ×1

unix ×1