Please see this


Contents

- INDEX
- Unix Scripts Index
- HP-UX
- Solaris
- Linux Index
- General Unix
- Unix Networking
- Other Unix types
- Unix databases

Associated Information

- none

Built in variables

my_prog arg1 arg2 arg3 is equivalent to $0 $1 $2 $3

  • $0 - gives program name, i.e. my_prog
  • $* - gives all arguements i.e. $i , $2 and $3
  • $# - gives number of arguements, i.e. 3
  • $? - gives return code
  • $$ - gives pid, useful for assigning unique names, e.g. > /tmp/file.$$

These can be used to create a usage statement (which is always good practice), e.g.

#!/usr/bin/sh USAGE="usage: $0 arg1 arg2 arg3" if [ $# -ne 3 ] then echo "$USAGE" exit 1 fi

Parameter Subsitution

${variable:-string}

will show variable if set otherwise string

${variable:=string}

if variable is not set, use string and set variable to the value of string for


Copyright 2000 Intronet Computers Ltd
Email: Intronet Computers for enquiries