0

How can I hide the command not found in my bash script? Im curious because everything works great except the sloppy "command not found message"

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

This is the error im getting

 ./project.sh: line 49: (myusernameisherebutimhidingit): command not found
1
  • 1
    Don't hide it, fix it. I don't know what if $user_name is supposed to do, but if you want to say "if $user_name is non-empty" you should use if [ -n "$user_name" ]. Commented Apr 12, 2016 at 23:40

1 Answer 1

1

The problem is that you are trying to run the command $user_name at several places, you probably want to replace $user_name with a check for the value of user name.

Sign up to request clarification or add additional context in comments.

2 Comments

what do u mean im new to this?
@ergology: $user_name && "exit" 2> /dev/null does not make any sense at all. Without knowing what it's supposed to do, it's hard to tell you how to do it correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.