Previous | Table of Contents | Next |
Notation | Description |
---|---|
$#argv | Count the number of command-line arguments. |
$* | Display all arguments. |
$argv | Display all arguments. |
$argv [1-3] | Display arguments 1 through 3. |
$0 | Display the command used to run the shell script. |
$argv [n] | Display the nth argument. |
$argv [$#argv} | Display the last argument. |
Character | Term | Description |
---|---|---|
\ | Backslash | Nullifies the special meaning of the following shellmetacharacter, including another backslash. |
`` | Backquotes | The output is substituted as if it were typed in place of thecommand. Refer to the shell manual pages for more information. |
'' | Single quote | Nullifies the special meaning of all characters except bang(!), the backslash (\), and the single quote itself ('). Singlequotes are more restrictive than double quotes and do not permitvariable or backquote expansion. |
"" | Double quotes | Nullifies the special meaning of all special characters exceptbang (!), backquote (``), and dollar sign ($). Permits variable andbackquote expansion. |
Feature | Bourne and Korn | C |
---|---|---|
Single-character wildcard | ? | ? |
Any number of characters | * | * |
Set of single characters | [abc] | [abc] |
Range of single characters | [a-c] | [a-c] |
Inverse range of single characters | [!a-c] | N/A |
Feature | Bourne | Korn | C |
---|---|---|---|
Assigning regular variables | x=1 | x=1 | set x = 1 |
Accessing regular variables | echo $x | echo $x | echo $x |
Assigning arrays | N/A | y[0]=1; y[1]=2 | set y=(1 2) |
Accessing array elements | N/A | echo $y | echo $y[1] $y[2] |
echo ${y[1]} | |||
Accessing entire array | N/A | echo ${y[*]} | echo $y |
Exporting variables (make global) | export var | export var | use setenv command |
Command-line arguments | N/A | N/A | $argv, $#argv, $argv[1} |
Positional parameters | $*, $#, $1 | $*, $#, $1 | $*, $1 |
Setting positional parameters | set a b c | set a b c | N/A |
Feature | Bourne | Korn | C |
---|---|---|---|
STDOUT to file | >filenameor 1>filename | >filenameor 1>filename | >filename |
STDIN from file | <filenameor 0<filename | <filenameor 0<filename | <filename |
STDERR to file | 2>filename | 2>filename | N/A |
Output and errors to file | 2>&1 | 2>&1 | >&filename |
Output to next command | | cmd | | cmd | | cmd |
Output and errors to next command | 2>&1 | | 2>&1 | | |& |
Feature | Bourne | Korn | C |
---|---|---|---|
Display text and variables | echo | print or echo | echo |
Feature | Bourne | Korn | C |
---|---|---|---|
Read keyboard input | readname1name2. . . | readname1name2. . . | set var = $< |
Feature | Bourne | Korn | C |
---|---|---|---|
Perform a calculation | var=`expr a + b` | let var= a + b | @ var = (a + b) |
Test a relational condition | var=`expr a < b` | let var=a < b | @ var = (a < b) |
Feature | Bourne | Korn | C |
---|---|---|---|
Command substitution | `command` | $(command) or`command` | `command` |
Previous | Table of Contents | Next |