linux - 隐藏命令未找到 bash 脚本

标签 linux bash

如何隐藏 bash 脚本中未找到的命令?我很好奇,因为除了草率的“命令未找到消息”之外,一切都运行良好

read user_name
if $user_name && exit 2> /dev/null
then
        exit 0
elif egrep "^${user_name}": /etc/passwd 2> /dev/null
then
        finger $user_name
        exit 0
elif
        until egrep "^${user_name}:" /etc/passwd || $user_name && "exit"  2> /dev/null
        do
        echo "try again or type exit to quit"
        read user_name
        if egrep -i "^${user_name}": /etc/passwd
        then
                finger $user_name
        fi
        done
then
        finger $user_name
        exit 0



fi

这是我遇到的错误

 ./project.sh: line 49: (myusernameisherebutimhidingit): command not found

最佳答案

问题是您尝试在多个位置运行命令 $user_name,您可能希望将 $user_name 替换为检查用户名的值。

关于linux - 隐藏命令未找到 bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36585808/

相关文章:

linux - 用于递减传递参数的 Shell 脚本

bash - 如何在 shell 脚本中获取 INI 值?

c++ - waitpid() 给出不正确的退出代码

linux - 检查后如何从数组中删除文件?

linux - 将 awk 输出保存到变量

c++ - fork() 并释放所有分配的内存

git - 如何从 git 存储库中删除外部空文件夹?

python - 在 Python 中的特定时间生成信号

c++ - 写入 SSD 上仅附加文件的最佳方式

linux - VNC 服务器使用多少内存?