AT&T UNIX™PC Unix System V Users Manual - tenox
AT&T UNIX™PC Unix System V Users Manual - tenox AT&T UNIX™PC Unix System V Users Manual - tenox
SH ( 1 ) SH( 1) case word in [ pattern [ 1 pattern ] ... ) list ;; ] . . . esac A case command executes the list associated with the first pattern that matches word. The form of the patterns is the same as that used for file-name generation (see File Name Generation below). if list then list [ elif list then list ] . . . [ else list ] fi The list following if is executed and, if it returns a zero exit status, the list following the first then is executed. Otherwise, the list following elif is executed and, if its value is zero, the list following the next then is executed. Failing that, the else list is executed. If no else list or then list is executed, then the if command returns a zero exit status. while list do list done A while command repeatedly executes the while list and, if the exit status of the last command in the list is zero, executes the do list; otherwise the loop terminates. If no commands in the do list are executed, then the while command returns a zero exit status; until may be used in place of while to negate the loop termination test. (list) Execute list in a sub-shell. {list;} list is simply executed. The following words are only recognized as the first word of a command and when not quoted: if then else elif fi case esa.c for while until do done { } Comments. A word beginning with # causes that word and all the following characters up to a new-line to be ignored. Command Substitution. The standard output from a command enclosed in a pair of grave accents ( ' ' ) may be used as part or all of a word; trailing newlines are removed. Parameter Substitution. The character $ is used to introduce substitutable parameters . Positional parameters may be assigned values by set. Variables may be set by writing: name=value [ name=value ] ... Pattern-matching is not performed on value. ${parameter} A parameter is a sequence of letters, digits, or underscores (a name), a digit, or any of the characters *, @, #, ?, -, �. $, and ! . The value, if any, of the parameter is substituted. The braces are required only when parameter is followed by a letter, digit, or underscore that is not to be interpreted as part of its name. A name must begin with a letter or underscore. If parameter is a digit then it is a - 2-
SH ( 1 ) SH(l) positional parameter. If parameter is * or @, then all the positional parameters, starting with $1, are substituted (separated by spaces). Parameter $0 is set from argument zero when the shell is invoked. ${parameter:-word} If parameter is set and is non-null then substitute its value; otherwise substitute word. ${parameter:=word} If parameter is not set or is null then set it to word; the value of the parameter is then substituted. Positional parameters may not be assigned to in this way. ${parameter:?word} If parameter is set and is non-null then substitute its value; otherwise, print word and exit from the shell. If word is omitted, then the message "parameter null or not set" is printed. ${parameter:+word} If parameter is set and is non-null then substitute word; otherwise substitute nothing. In the above, word is not evaluated unless it is to be used as the substituted string, so that, in the following example, pwd is executed only if d is not set or is null: echo ${d:- 'pwd '} If the colon (:) is omitted from the above expressions, then the shell only checks whether parameter is set or not. The following parameters are automatically set by the shell: # The number of positional parameters in decimal. Flags supplied to the shell on invocation or by the set command. ? The decimal value returned by the last synchro nously executed command. $ The process number of this shell. The process number of the ·last background command invoked. The following parameters are used by the shell: HOME The default argument (home directory) for the cd command. PATH The search path for commands (see Execution below). The user may not change PATH if executing under rsh . CDPATH The search path for the cd command. MAIL If this variable is set to the name of a mail file, PSl PS2 IFS then the shell informs the user of the arrival of mail in the specified file. Primary prompt string, by default "$ ". Secondary prompt string, by default "> " Internal field separators, normally space, tab, and new-line. - 3 -
- Page 468 and 469: PASTE (l) PASTE (l) pr(l): pr -t -
- Page 471 and 472: PR (l) PR (l) NAME pr - print files
- Page 473 and 474: PROF ( 1) PROF ( 1) NAME prof - dis
- Page 475 and 476: PRS ( l ) PRS ( l ) NAME prs - prin
- Page 477 and 478: PRS ( 1 ) PRS ( 1 ) TABLE 1 (Contin
- Page 479 and 480: PS ( l ) PS ( l ) NAME ps - report
- Page 481: PS (l) PS (l) WCHAN (1) The event f
- Page 484 and 485: PTX ( 1) PTX ( 1) SEE ALSO nroff( l
- Page 487 and 488: REGCMP ( 1 ) REGCMP (l) NAME regcmp
- Page 489: RM ( l ) RM (l) NAME rm, rmdir - re
- Page 492 and 493: I�
- Page 495: SCCSDIFF ( 1 ) SCCSDIFF ( 1 ) NAME
- Page 499 and 500: SDB ( l ) SDB ( 1) NAME sdb - symbo
- Page 501 and 502: � I SDB ( 1) SDB ( 1) file may ov
- Page 503 and 504: SDB ( 1) SDB ( 1) e directory file-
- Page 505 and 506: SDB ( 1 ) SDB ( 1 ) execution. B Pr
- Page 507: SDB ( 1 ) SDB ( 1 ) WARNINGS BUGS W
- Page 510 and 511: SDIFF ( 1) SDIFF(l) On exit from th
- Page 512 and 513: SED ( 1) SED ( 1) In the following
- Page 515 and 516: SETPRINT ( 1 ) SETPRINT ( 1 ) NAME
- Page 517: -� SH ( l ) NAME SH ( l ) sh, rsh
- Page 521 and 522: SH ( 1 ) word >> word
- Page 523 and 524: SH ( 1 ) SH ( 1) cd [ arg ] Change
- Page 525 and 526: SH (l) SH (l) Invocation . If the s
- Page 527 and 528: SHFORM (I) {AT&T UNIX PC only ) SHF
- Page 529 and 530: ( \ SHFORM(I) (AT&T UNIX PC only )
- Page 531 and 532: SIZE ( 1 ) SIZE ( 1) NAME size - pr
- Page 533: �· ! SLEEP (I) SLEEP (I) NAME sl
- Page 536 and 537: SORT(l) SORT(l) 0 The next argument
- Page 538 and 539: SPELL {l) SPELL (l) FILES spellin s
- Page 540 and 541: n__
- Page 543 and 544: STTY ( 1) STTY(l) NAME stty - set t
- Page 545: STTY ( 1) lfkc ( -lfkc) echonl ( -e
- Page 548 and 549: �· ·· .... . _ .....
- Page 550 and 551: �- . .�
- Page 552 and 553: � ·. ____ .
- Page 554 and 555: TABS (1) TABS ( 1) -u 1,12,20,44 UN
- Page 556 and 557: � \_ )
- Page 559 and 560: TAR ( 1 ) TAR ( 1) NAME tar - tape
- Page 561 and 562: TBL ( I ) TBL ( I ) NAME tbl - form
- Page 563 and 564: TBL(l) TBL(l) BUGS See BUGS under n
- Page 565: TC ( l ) TC ( l ) NAME tc - phototy
SH ( 1 ) SH(l)<br />
positional parameter. If parameter is * or @, then all the<br />
positional parameters, starting with $1, are substituted<br />
(separated by spaces). Parameter $0 is set from argument<br />
zero when the shell is invoked.<br />
${parameter:-word}<br />
If parameter is set and is non-null then substitute its<br />
value; otherwise substitute word.<br />
${parameter:=word}<br />
If parameter is not set or is null then set it to word; the<br />
value of the parameter is then substituted. Positional<br />
parameters may not be assigned to in this way.<br />
${parameter:?word}<br />
If parameter is set and is non-null then substitute its<br />
value; otherwise, print word and exit from the shell. If<br />
word is omitted, then the message "parameter null or not<br />
set" is printed.<br />
${parameter:+word}<br />
If parameter is set and is non-null then substitute word;<br />
otherwise substitute nothing.<br />
In the above, word is not evaluated unless it is to be used as the<br />
substituted string, so that, in the following example, pwd is executed<br />
only if d is not set or is null:<br />
echo ${d:- 'pwd '}<br />
If the colon (:) is omitted from the above expressions, then the<br />
shell only checks whether parameter is set or not.<br />
The following parameters are automatically set by the shell:<br />
# The number of positional parameters in decimal.<br />
Flags supplied to the shell on invocation or by the<br />
set command.<br />
? The decimal value returned by the last synchro<br />
nously executed command.<br />
$ The process number of this shell.<br />
The process number of the ·last background command<br />
invoked.<br />
The following parameters are used by the shell:<br />
HOME The default argument (home directory) for the cd<br />
command.<br />
PATH The search path for commands (see Execution<br />
below). The user may not change PATH if executing<br />
under rsh .<br />
CDPATH<br />
The search path for the cd command.<br />
MAIL If this variable is set to the name of a mail file,<br />
PSl<br />
PS2<br />
IFS<br />
then the shell informs the user of the arrival of<br />
mail in the specified file.<br />
Primary prompt string, by default "$ ".<br />
Secondary prompt string, by default "> "<br />
Internal field separators, normally space, tab,<br />
and new-line.<br />
- 3 -