home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / man / cat1 / ksh.0 < prev    next >
Text File  |  1993-12-07  |  52KB  |  1,255 lines

  1.  
  2.  
  3.  
  4. KSH(1)                                                     KSH(1)
  5.  
  6.  
  7. NNAAMMEE
  8.        ksh - Bourne / Korn Shell (Public Domain)
  9.  
  10. SSYYNNOOPPSSIISS
  11.        kksshh [--sstt] [--cc _c_o_m_m_a_n_d] [_f_i_l_e [_a_r_g_u_m_e_n_t _._._.]]
  12.  
  13. IINNTTRROODDUUCCTTIIOONN
  14.        This  document  only  summarizes  the  System V, release 2
  15.        shell features.  All of the System V features  except  for
  16.        ``restricted  mode''  are  implemented.  See also the BUGS
  17.        section.
  18.  
  19.        Features of the Korn shell are described in  more  detail.
  20.        Only  a  subset  of  the Korn shell features are currently
  21.        implemented.
  22.  
  23. DDEESSCCRRIIPPTTIIOONN
  24.    CCoommmmaanndd ssyynnttaaxx
  25.        The ``#'' character begins a one-line comment, unless  the
  26.        ``#''  occurs  inside  a  word.   The tokens ``;'', ``|'',
  27.        ``&'', ``;;'', ``||'', ``&&'', ``('', and ``)''  stand  by
  28.        themselves.   A  _w_o_r_d  is  a  sequence  of  any other non-
  29.        whitespace  characters,  which  may  also  contain  quoted
  30.        strings  (quote  character  are  ``''', ``"'', ```'', or a
  31.        matching ``${ }''  or  ``$(  )''  pair).   A  _n_a_m_e  is  an
  32.        unquoted  word  made up of letters, digits, or ``_''.  Any
  33.        number of whitespace characters (space and tab) may  sepa-
  34.        rate words and tokens.
  35.  
  36.        In  the  following  syntax, { ... }? indicates an optional
  37.        thing, { ... }* indicates zero or more repetitions, {  ...
  38.        | ... } indicates alternatives.
  39.  
  40.        statement:
  41.               (( list ))
  42.               {{ list ;; }}
  43.               ffoorr name { iinn { word }* }? ddoo list ;; ddoonnee
  44.               { wwhhiillee | uunnttiill } list ;; ddoo list ;; ddoonnee
  45.               iiff  list ;; tthheenn list ;; { eelliiff list ;; tthheenn list ;; }*
  46.               { eellssee list ;; }?ffii
  47.               ccaassee name iinn { (( word { || word } )) list ;;;; }* eessaacc
  48.               ffuunnccttiioonn name {{ list ;; }}
  49.               name (()) {{ list ;; }}
  50.               ttiimmee pipe
  51.               The opening parenthesis of the pattern is optional.
  52.               Redirection  may occur at the beginning or end of a
  53.               statement.
  54.  
  55.        command:
  56.               { name=word }* { word }*
  57.               Redirection may occur anywhere in a command.
  58.  
  59.        list:
  60.               cond
  61.  
  62.  
  63.  
  64.                             April 1992                          1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. KSH(1)                                                     KSH(1)
  71.  
  72.  
  73.               cond ;; list
  74.               cond && list
  75.  
  76.        cond:
  77.               pipe
  78.               pipe &&&& cond
  79.               pipe |||| cond
  80.  
  81.        pipe:
  82.               statement { || statement }*
  83.  
  84.    AAlliiaass eexxppaannssiioonn
  85.        Alias expansion occurs when the first word of a  statement
  86.        is  a  defined  alias,  except  when that alias is already
  87.        being expanded.  It also occurs after the expansion of  an
  88.        alias whose definition ends with a space.
  89.  
  90.    SShheellll vvaarriiaabblleess
  91.        The  following  standard special variables exist: !!, ##, $$,
  92.        --, ??.
  93.  
  94.        _      In interactive use this parameter  is  set  to  the
  95.               last  word of the previous command.  When a command
  96.               is executed this parameter is set to the full  path
  97.               of  the  command  and placed in the environment for
  98.               the command.  See also MMAAIILLPPAATTHH.
  99.  
  100.        CDPATH The search path for the _c_d command.
  101.  
  102.        ENV    If this variable is set at start-up (after any pro-
  103.               file  files  are  executed),  the expanded value is
  104.               used as shell start-up file.  It typically contains
  105.               function and alias definitions.
  106.  
  107.        FCEDIT The  editor used by the _f_c command.  During startup
  108.               the shell checks the value of  FFCCEEDDIITT,  EEDDIITTOORR  and
  109.               finally  VVIISSUUAALL  to  try  and determin what command
  110.               line edit mode to  use.   Note  that  this  is  not
  111.               strictly ksh compatible behaviour.
  112.  
  113.        IFS    _I_n_t_e_r_n_a_l  _f_i_e_l_d _s_e_p_a_r_a_t_o_r, used during substitution
  114.               and the _r_e_a_d command.
  115.  
  116.        HOME   The default directory for the _c_d command.
  117.  
  118.        MAIL   If set, the user will be informed of the arrival of
  119.               mail  in  the named file.  This variable is ignored
  120.               if the MMAAIILLPPAATTHH variable is set.
  121.  
  122.        MAILCHECK
  123.               How often, in seconds, the  shell  will  check  for
  124.               mail  in the file(s) specified by MMAAIILL or MMAAIILLPPAATTHH.
  125.               If 0, the shell checks  before  each  prompt.   The
  126.               default is 600 seconds.
  127.  
  128.  
  129.  
  130.                             April 1992                          2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. KSH(1)                                                     KSH(1)
  137.  
  138.  
  139.        MAILPATH
  140.               A  list  of files to be checked for mail.  The list
  141.               is colon separated, and each file may  be  followed
  142.               by  a ?? and a message to be printed if new mail has
  143.               arrived.  Command  and  parameter  substitution  is
  144.               performed  on  the message, and the parameter $$__ is
  145.               set to the name of the file.  The  default  message
  146.               is ``you have mail in $_''.
  147.  
  148.        PATH   The  search  path  for  executable commands and ..'d
  149.               files.
  150.  
  151.        PPID   The process number of the parent of the shell.
  152.  
  153.        PS1 PS2
  154.               PPSS11 is the primary prompt for  interactive  shells.
  155.               Dollar substitution is performed, and !! is replaced
  156.               with the command number (see _f_c).
  157.  
  158.        PWD OLDPWD
  159.               The current and previous working directories.
  160.  
  161.        RANDOM A random integer.  The random number generator  may
  162.               be  seeded  by  assigning  an integer value to this
  163.               variable.
  164.  
  165.        SECONDS
  166.               The number of seconds since  the  shell  timer  was
  167.               started  or  reset.   Assigning an integer value to
  168.               this variable resets the timer.
  169.  
  170.        COLUMNS
  171.               The width to use for the commandline editing (emacs
  172.               mode only).
  173.  
  174.        HISTFILE
  175.               The  name of the file to read initial history from.
  176.               The default is "$$HHOOMMEE//..ppddkksshh__hhiisstt".  When the shell
  177.               exits  it will overwrite this file with its current
  178.               history.   This  behaviour  will  almost  certainly
  179.               cause  grief  when multiple shells are being run by
  180.               the same user.   Making  the  file  read-only  will
  181.               allow  each  shell  to start with a set history and
  182.               avoid overwriting the file.
  183.  
  184.        HISTSIZE
  185.               The number of history items to save in HHIISSTTFFIILLEE.
  186.  
  187.    SSuubbssttiittuuttiioonn
  188.        In addition to the System Vr2 substitutions, the following
  189.        are available.
  190.  
  191.        $(command)
  192.               Like `command`, but no escapes are recognized.
  193.  
  194.  
  195.  
  196.                             April 1992                          3
  197.  
  198.  
  199.  
  200.  
  201.  
  202. KSH(1)                                                     KSH(1)
  203.  
  204.  
  205.        $(<file)
  206.               Equivalent to $(cat file), but without forking.
  207.  
  208.        ${#var}
  209.               The  length of the string value of _v_a_r, or the num-
  210.               ber of arguments if _v_a_r is ** or @@.
  211.  
  212.        ${var#pattern} ${var##pattern}
  213.               If _p_a_t_t_e_r_n matches the beginning of  the  value  of
  214.               _v_a_r, the matched text is deleted from the result of
  215.               substitution.  A single ## results in  the  shortest
  216.               match, two ##'s results in the longest match.
  217.  
  218.        ${var%pattern} ${var%%pattern}
  219.               Like ## substition, but deleting from the end of the
  220.               value.
  221.  
  222.    EExxpprreessssiioonnss
  223.        Expressions can be