Script to execute with switch

Hello
I want to create a script which will require a mandatory value and optional values which can be supplied using switch. If optional values are not supplied, the script will use the default values mentioned in the script.

For example, how we create user in linux systems.

Please help/guide.

Is this homework ?

Any effort from your side ?

Regards
Peasant.

Hello Peasant

Actually I was searching the easiest way to get the job done....some thing like ..

sh myscript.sh <dir_name> -w <value> -c <value> 

Where <dir_name> is mandatory, and values supplied with -w or -c is optional. If optional values are not supplied, default value will be taken.

Looks like a job for getops with OPTIND check for default (no options).

You might want to take a look at the examples search engine provides.