Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ specialchar(5) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

csh(1)

ksh(1)

sh(1)

specialchar(5)                                               specialchar(5)

NAME
     specialchar - shell metacharacters

ARGUMENT AND COMMAND SEPARATORS

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | Blank                 |  Argument separators, depending on the value  |
    | Newline               |  of the IFS variable                          |
    | Tab                   |                                               |
    |_______________________|_______________________________________________|
    | Newline               |  End of command                               |
    |_______________________|_______________________________________________|
    | |                     |  Pipe symbol                                  |
    |_______________________|_______________________________________________|
    | ;                     |  End of command                               |
    |_______________________|_______________________________________________|
    | &                     |  End of command; a command terminated with    |
    |                       |  this symbol is started in the background.    |
    |_______________________|_______________________________________________|
    | ||                    |  ORIF; the next command is executed only if   |
    |                       |  the preceding command returns a non-zero exit|
    |                       |  status.                                      |
    |_______________________|_______________________________________________|
    | &&                    |  ANDIF; the next command is executed only if  |
    |                       |  the preceding command returns an exit status |
    |                       |  of zero.                                     |
    |_______________________|_______________________________________________|

COMMAND GROUPING

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | (commandlist)        |  Execute commandlist in a subshell           |
    |_______________________|_______________________________________________|
    | { commandlist;}      |  Collect the output of all commands from      |
    |                       |  commandlist                                 |
    |_______________________|_______________________________________________|

COMMAND SUBSTITUTION

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | `command`             |  Replace command with its output              |
    |_______________________|_______________________________________________|







Page 1                       Reliant UNIX 5.44                Printed 11/98

specialchar(5)                                               specialchar(5)

FILENAME GENERATION

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | *                     |  As a pattern on its own: replaced by the list|
    |                       |  of all file names in the current directory   |
    |                       |  that do not begin with a period ".".         |
    |                       |                                               |
    |                       |  As part of a pattern: replaced by zero, one, |
    |                       |  or more characters to match the file names   |
    |                       |  matching the pattern.                        |
    |_______________________|_______________________________________________|
    | ?                     |  As a pattern on its own: replaced by the list|
    |                       |  of all file names in the current directory   |
    |                       |  that consist of exactly one character, except|
    |                       |  for a period.                                |
    |                       |                                               |
    |                       |  As part of a pattern: replaced by exactly one|
    |                       |  character to match the file names matching   |
    |                       |  the pattern.                                 |
    |_______________________|_______________________________________________|
    | [s]                   |  Replaced by exactly one character from the   |
    |                       |  character string s to match the file names   |
    |                       |  matching the pattern.                        |
    |_______________________|_______________________________________________|




























Page 2                       Reliant UNIX 5.44                Printed 11/98

specialchar(5)                                               specialchar(5)

     ________________________________________________________________________
    | [c1-c2]               |  Replaced by exactly one character from the   |
    |                       |  range between c1 and c2 (c1 and c2 inclusive)|
    |                       |  to match the file names matching the pattern.|
    |                       |  c1 and c2 must be ordinary characters. The   |
    |                       |  characters which collate in the range c1-c2  |
    |                       |  are determined by the ASCII collating        |
    |                       |  sequence.                                    |
    |                       |                                               |
    |                       |  Expressions of type [s] and [c1-c2] can be   |
    |                       |  combined: [s1c1-c2s2].                       |
    |_______________________|_______________________________________________|
    | [!s]                  |  Replaced by exactly one character excluding  |
    |                       |  those contained in the character string s to |
    |                       |  match the file names matching the pattern.   |
    |_______________________|_______________________________________________|
    | [!c1-c2]              |  Replaced by exactly one character excluding  |
    |                       |  those in the range c1 through c2 inclusive to|
    |                       |  match file names matching the pattern (see   |
    |                       |  [c1-c2]).                                    |
    |                       |                                               |
    |                       |  Expressions of type [!s] and [!c1-c2] can be |
    |                       |  combined: [!s1c1-c2s2].                      |
    |_______________________|_______________________________________________|
    | [[:class:]]           |  (ksh only) Replaced by exactly one character |
    |                       |  from the character class class. class can be:|
    |                       |                                               |
    |                       |  alpha     any letter                         |
    |                       |                                               |
    |                       |  upper     any uppercase letter               |
    |                       |                                               |
    |                       |  lower     any lowercase letter               |
    |                       |                                               |
    |                       |  digit     any decimal digit (0 through 9)    |
    |                       |                                               |
    |                       |  xdigit    any hexadecimal digit (0 through 9,|
    |                       |            a through f, and A through F)      |
    |                       |                                               |
    |                       |  alnum     any alphanumeric character         |
    |                       |            (letters and digits)               |
    |                       |                                               |
    |                       |  space     any character producing white space|
    |                       |  in                                           |
    |                       |            displayed text                     |
    |                       |            (e.g. blanks or tabs)              |
    |                       |                                               |
    |                       |  blank     blanks or tabs                     |
    |                       |                                               |
    |                       |  punct     any separator                      |
    |                       |                                               |
    |_______________________|_______________________________________________|



Page 3                       Reliant UNIX 5.44                Printed 11/98

specialchar(5)                                               specialchar(5)

    |                       |  print     any printable character (including |
    |                       |            the characters in space)           |
    |                       |                                               |
    |                       |  graph     any printable character with a     |
    |                       |  visible                                      |
    |                       |            representation (excluding the char-|
    |                       |  acters in space)                             |
    |                       |                                               |
    |                       |  cntrl     any control character              |
    |_______________________|_______________________________________________|
    | [[=c=]]               |  (ksh only) Replaced by exactly one character |
    |                       |  or a collating element that has the same     |
    |                       |  relative order as c. c must not be an equals |
    |                       |  sign = or a right square bracket ].          |
    |_______________________|_______________________________________________|
    | [[.cc.]]              |  (ksh only) Replaced by exactly one collating |
    |                       |  element. Multi-character collating elements  |
    |                       |  must be represented in this form to distin-  |
    |                       |  guish them from ordinary characters. cc has  |
    |                       |  to be defined as a valid collating element in|
    |                       |  the internationalized environment.           |
    |_______________________|_______________________________________________|

REDIRECTION OF STANDARD OUTPUT

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | >file                 |  Redirect standard output to file, deleting   |
    |                       |  original contents                            |
    |_______________________|_______________________________________________|
    | >>file                |  Redirect standard output to file, retaining  |
    |                       |  original contents                            |
    |_______________________|_______________________________________________|
    | >&digit               |  Redirect standard output to the file associ- |
    |                       |  ated with the file descriptor digit          |
    |_______________________|_______________________________________________|
    | >&-                   |  Close standard output                        |
    |_______________________|_______________________________________________|















Page 4                       Reliant UNIX 5.44                Printed 11/98

specialchar(5)                                               specialchar(5)

REDIRECTION OF STANDARD INPUT

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | <file                 |  Redirect standard input to file              |
    |_______________________|_______________________________________________|
    | <<argument            |  Start a "here" document                      |
    |_______________________|_______________________________________________|
    | <<-argument           |  Start a "here" document, stripping leading   |
    |                       |  tabs                                         |
    |_______________________|_______________________________________________|
    | <&digit               |  Redirect standard input to the file associ-  |
    |                       |  ated with the file descriptor digit          |
    |_______________________|_______________________________________________|
    | <&-                   |  Close standard input                         |
    |_______________________|_______________________________________________|

SHELL VARIABLES AND PARAMETERS

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | name=value            |  Assign a value to the variable name          |
    |_______________________|_______________________________________________|
    | $name                 |  Value of the variable name; keyword parameter|
    |                       |                                               |
    | ${name}               |  Same as $name; the braces delimit the vari-  |
    |                       |  able name from following digits or letters.  |
    |_______________________|_______________________________________________|
    | ${name-defaultvalue} |  Replace with defaultvalue if name is unde-  |
    |                       |  fined                                        |
    |                       |                                               |
    | ${name=defaultvalue} |  Assign defaultvalue if name is undefined    |
    |_______________________|_______________________________________________|



















Page 5                       Reliant UNIX 5.44                Printed 11/98

specialchar(5)                                               specialchar(5)

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | ${name?defaultvalue} |  Shell terminates execution with error message|
    |                       |  parameter : defaultvalue if name is unde-   |
    |                       |  fined                                        |
    |                       |                                               |
    | ${name+defaultvalue} |  Replace with the null string if name is unde-|
    |                       |  fined. Replace with defaultvalue if name is |
    |                       |  defined.                                     |
    |_______________________|_______________________________________________|
    | ${name:-defaultvalue}|  Replace with defaultvalue if name is unde-  |
    |                       |  fined or its value is the null string        |
    |                       |                                               |
    | ${name:=defaultvalue}|  Assign defaultvalue if name is undefined or |
    |                       |  its value is the null string                 |
    |                       |                                               |
    | ${name:?defaultvalue}|  Shell terminates execution with error message|
    |                       |  parameter : defaultvalue if name is unde-   |
    |                       |  fined or its value is the null string        |
    |                       |                                               |
    | ${name:+defaultvalue}|  Replace with the null string if name is unde-|
    |                       |  fined or its value is the null string.       |
    |                       |  Replace with defaultvalue if name is defined|
    |                       |  and its value is not the null string.        |
    |_______________________|_______________________________________________|
    | $0                    |  0th command-line argument, i.e. the command  |
    |                       |  name, the shell script, or the current shell |
    |                       |                                               |
    | $1, $2, ... , $9      |  Positional parameters                        |
    |                       |                                               |
    | $*                    |  All command-line arguments                   |
    |                       |                                               |
    | "$*"                  |  All command-line arguments as a single argu- |
    |                       |  ment                                         |
    |                       |                                               |
    | $@                    |  All command-line arguments                   |
    |                       |                                               |
    | "$@"                  |  All command-line arguments as a separate     |
    |                       |  arguments                                    |
    |                       |                                               |
    | $#                    |  Number of command-line arguments, i.e.       |
    |                       |  excluding $0                                 |
    |_______________________|_______________________________________________|










Page 6                       Reliant UNIX 5.44                Printed 11/98

specialchar(5)                                               specialchar(5)

     ________________________________________________________________________
    | $$                    |  Process ID (PID) of the current shell        |
    |                       |                                               |
    | $!                    |  PID of the last command started in the back- |
    |                       |  ground                                       |
    |                       |                                               |
    | $?                    |  Exit status of the last executed command that|
    |                       |  was not started in the background            |
    |                       |                                               |
    | $-                    |  All options set in the current shell         |
    |_______________________|_______________________________________________|

SHELL FUNCTIONS

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | name() { cmdlist;}   |  Shell function; when name is invoked, the    |
    |                       |  commands from cmdlist are executed          |
    |_______________________|_______________________________________________|

QUOTING METACHARACTERS

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | \                     |  Escapes the next metacharacter               |
    |_______________________|_______________________________________________|
    | '...'                 |  Escapes all metacharacters; treat the con-   |
    |                       |  tents as a single argument                   |
    |_______________________|_______________________________________________|
    | "..."                 |  Does not escape the metacharacters $, `...`  |
    |                       |  and \; treat the contents as a single argu-  |
    |                       |  ment                                         |
    |_______________________|_______________________________________________|

MISCELLANEOUS

     ________________________________________________________________________
    | Metacharacter         |  Meaning                                      |
    |_______________________|_______________________________________________|
    | #                     |  Comment character in shell scripts           |
    |_______________________|_______________________________________________|
    | ;;                    |  Command list terminator within case con-     |
    |                       |  structs                                      |
    |_______________________|_______________________________________________|

SEE ALSO
     csh(1), ksh(1), sh(1).





Page 7                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026