使用bash版本3.2.57(1)-release(x86_64-apple-darwin14)
如何"重新分配"或"更改"读入变量的现有值.
如果用户输入字符串IAmString,我想propInput存储该值iamstring.我只是为了清酒而打印到控制台.
read userInput
echo ${userInput} | tr '[:upper:]' '[:lower:]'
Run Code Online (Sandbox Code Playgroud)
您应该存储命令的输出:
read userInput
userInput=$(echo "$userInput" | tr '[:upper:]' '[:lower:]')
Run Code Online (Sandbox Code Playgroud)