Hi. I have created a script that works perfect but I am now told that I could have done it better, but how?
This is an example of how I did mine:

function users

        echo "1. Password file"
        echo "Enter num: "

        read usernumber

        if [ $usernumber -eq 1 ]
        cat /etc/passwd       

        else if [ $usernumber -eq 2 ]
        cat etc/passwd

I have been told that I shouldn't have done it using else if but what other ways are there of doing it?


Recommended Answers

Well you could have used code tags.

Jump to Post

All 3 Replies

Well you could have used code tags.

Hmm... Is that the whole script? I'm not seeing the "users" function called anywhere, or even a terminating "}" for the function :)


The script here was just a quick example anyway I have sorted it I replaced if and else if with case.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.