when I should run the script, i want to pass an parameter.
based on the parameter, it should check and run only those function which is pass for that parameter.
---------- Post updated at 06:41 AM ---------- Previous update was at 06:40 AM ----------
like sh test.sh default,
so it should call only func1 and func2
or
sh test.sh xxxxx
then func2 func3 like that.
"Like that" is not too precise a specification. With a vague request like above I'm afraid yo need to be content with fuzzy answers. Like:
Use a case statement to scan through the possible parameter values and execute the functions accordingly.
"Default" usually is the fallback case when nothing is specified; it would be used / executed if NO parameters are given, i.e. $# == 0 . You could test that outside the case construct.
OK, brilliant, that's a start (talking of post#5)! You did not yet specify how those parameter(s) should look like ... one parameter, several characters/numbers?
Did you read bash 's man page on the case ... esac (a professional approach, btw)? It would lead you to something like