Linux Bash shell 脚本

标签 linux bash shell scripting

我的脚本有什么问题吗?我没有看到问题所在,很抱歉我是 Linux Shell 脚本新手。

# Skript: M122_Scripts/addPerson.sh
echo "Write youre name (: end with quit"
read $Name 
while true; do
if [ "$Name" = "quit" ]; then
echo "exit add person"
break
else
echo $name >> Filelist
echo $name
read $name
fi
done

最佳答案

您的脚本中有一些错误,请尝试以下操作:

#!/bin/bash

echo "Write youre name (: end with quit"
# wrong: read $Name
read Name
while true; do
    if [ "$Name" = "quit" ]; then
        echo "exit add person"
        break
    else
        echo $Name >> Filelist
        echo $Name
        # wrong: read $name
        read Name
    fi
done

关于Linux Bash shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53237865/

相关文章:

linux - 替换 JSON 配置文件中的日期

带中断的 Linux 串行通信

linux - 使用 gphoto2 捕获图像时如何创建校验和

bash - 在命令替换中使用变量

shell - 如果未设置,则从控制台读取 Makefile 变量

linux - jmeter执行复杂的shell命令

linux - Bash 编程 — 如何将字符串添加到文本文件中

linux - 如何编辑主机文件以连接到给定 ip 的本地主机端口?

bash - bash 脚本中的 mkdir 问题

linux - 无法使用 sudo -u username mkdir/var/log/test 创建目录