Recent Notes

Displaying keyword search results 1 - 2
Created by Dr. Xi on February 28, 2011 12:29:19    Last update: February 28, 2011 12:30:40
The Unix shell passes these parameters to the shell script: Variable Meaning $* A single string representing all command line arguments separated by $IFS (internal field separator, usually a space) $@ A sequence of strings representing the command line arguments. $1,$2...$n $1 is the first argument, $2 is the second argument, and so on... $0 The name of the script itself. $# The number of arguments. Example shell script ( sharg.sh ): #!/bin/sh echo $# arguments passed to $0: $@ ... Output for ./sharg.sh "a b c d" : 1 arguments passed to ./sharg.sh: a b c d here ... Output for ./sharg.sh a "b c" d : 3 arguments passed to ./sharg.sh: a b c d here ...
Created by Dr. Xi on May 29, 2007 03:48:01    Last update: May 29, 2007 03:49:54
The following applies to Bourne, Korn and Bash: $var or ${var} Replaced by the value of var . Use braces to avoid ambiguity. ${var-value} Use the value of var if set, use value otherwise. ${var+value} Use the value of value if var is set, use nothing otherwise. ${var=value} Use the value of var if set, other wise, use value and assign value to var . ${var?value} Use the value of var ; otherwise, print value to standard error and exit the current shell. If value is omitted, a standard error message is printed instead.