隐藏命令找不到bash脚本

时间:2016-04-12 23:19:52

标签: 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

1 个答案:

答案 0 :(得分:1)

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