Originally posted by: Wouter Liefting
If this is inside a tight loop, you may want to avoid calling multiple programs.
Here's an example of doing the same thing (grep & cut), but with a single call to awk:
crsctl status res | awk -F . "/ora\.$DATABASE\.(.+)\.svc/"' {print $3}'
or even better as this only checks the second field, then prints the third field - but I don't know if that's exactly what you want:
crsctl status res | awk -F . -v db="$DATABASE" '$2 == db {print $3}'
You should be able to do the same thing with sed and perl too.
For your second question, you can access the positional parameters from within your shell script with $1, $2, ... If it's just one or two parameters that you need, that's enough. If you want to pass a whole bunch of options and parameters, you may want to read up on getopt, and argument parsing using shift.