How do I create function in cmd line RHEL5?

Sp0cky used Ask the Experts™
I thought it was:

functioname() {command 1 command2}

or like:

testfunction() {echo employee_name echo employee_number}

is this not correct?  does it have to be done in vi editor or something?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007
functions are best defined as multiline, eg:

testfunction() {
  echo employee_name
  echo employee_number

However, you don't need a function if you aren't using any parameters.  In that instance, you can use an alias, eg:

alias testalias='echo employee_name;echo employee_number'

Note that functions and aliases are a feature of the shell you are using.  Some shells use a slightly different syntax.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial