Home arrow Shell Programming arrow Write a procedure in UNIX Shell Scripting
Write a procedure in UNIX Shell Scripting PDF
Saturday, 23 January 2010
To create a procedure in a shell script use the following example:

Exxample of a procedure / function in UNIX Shell Scripting
  1. #!/bin/sh
  2.  
  3. my_option="option"
  4.  
  5. my_function()
  6. {
  7. param=$1
  8. echo "now executing custom function with parameter: "$param
  9. }
  10.  
  11. my_function $my_option


See example 2 for a procedure without parameters:

Example 2: a procedure without parameters
  1. #!/bin/sh
  2.  
  3. my_function()
  4. {
  5.   echo "now executing custom function"
  6. }
  7.  
  8. my_function

 

 

 
< Prev   Next >

Other BSD Systems

OpenBSD

Polls

Best BSD firewall?