用户在bash脚本上输入txt文件

我正在尝试将bash上的用户输入添加到txt文件中,但是当我打开文件时,它仅显示写在代码上的文本。这是代码...

if [ $opcao2==1 ]
then
echo "Esolheu Inserir uma antena"
echo "Nome: "
read $nome
echo "fornecedor:"
read $fornecedor
echo "Preco: "
read $preco
echo "Sinais: "
read $sinais
echo "Nome:" $nome  >> antenas.txt
wanderer0 回答:用户在bash脚本上输入txt文件

if [ "$opcao2" = 1 ]
then
echo "Esolheu Inserir uma antena"
echo "Nome: "
read nome
echo "Nome:" $nome  >> antenas.txt

重要的是read语句。重要的是要理解,您正在设置变量时不带美元,而将变量的值与$一起使用。

因此read语句中没有$,但是在回显中我们需要它使用变量的值。

本文链接:https://www.f2er.com/3131861.html

大家都在问