📄 sh5.1
字号:
.\" SCCSID: @(#)sh5.1 8.1 9/11/90.TH sh5 1 .SH Namesh5, rsh5 \- shell, the standard/restricted command programming language.SH Syntax.B sh5[\fB\-acefhiknrstuvx\fR] [\|\fIargs\fR\|].br.B rsh5[\fB\-acefhiknrstuvx\fR] [\|\fIargs\fR\|].SH Description.NXB "sh5 command interpreter".NXR "rsh5 program"The.PN sh5program is a command line interpreter and programming languagethat executes commands read from a terminalor a file.The.PN rsh5program is a restricted version of the standard command interpreter.PN sh5 . It is used to set up login names and execution environments whosecapabilities are more controlled than those of the standard shell.See.B Invocation\^belowfor the meaning of arguments to the shell.This version of the shell is from System V Release 2. For furtherinformation about the standard Bourne shell interpreter, see .MS sh 1 ..SS Definitions.NXR "blank" "defined".NXR "parameter" "defined".NXR "name" "defined"A blank is a tab or a space. A nameis a sequence of letters, digits, or underscores beginning with a letteror underscore.A parameteris a name, a digit, or any of the characters.BR \(** ,.BR @ ,.BR # ,.BR ? ,.BR \- ,.BR $ ,and.BR !\\^ ..SS Commands.NXR "simple command" "defined" A simple command is a sequence of nonblankwords separated by blanks.The first word specifies the name of the command tobe executed.Except as specified below,the remaining words are passed as argumentsto the invoked command.The command name is passed as argument 0.For further information, see.MS execve 2 .The value of a simple command is its exit statusif it terminates normally, or (octal) 200+\fIstatus\^\fP ifit terminates abnormally. For a list of status values, see.MS signal 3 ..PPA pipeline is a sequence of one or morecommands separated by .BR |(or, for historical compatibility, by.BR ^ ). .NXR "pipeline" "defined"The standard output of each command but the lastis connected by a.MS pipe 2to the standard input of the next command.Each command is run as a separate process.The shell waits for the last command to terminate.The exit status of a pipeline is the exit status of the last command..PPA list is a sequence of one or more.NXR "pipelines" "lists"pipelines separated by.BR ; ,.BR & ,.BR && ,or.BR || ,and optionally terminated by.B ;or.BR & .Of these four symbols,.B ;and.B &have equal precedence,which is lower than that of.B &&and.BR || .The symbols.B &&and.B ||also have equal precedence.A semicolon.RB ( ; )causes sequential execution of the preceding pipeline. An ampersand.RB ( & )causes asynchronous executionof the preceding pipeline. That is, the shell doesnot wait for that pipeline to finish.The symbol.B &&.RB (| |)causes thelist following it to be executed only if the precedingpipeline returns a zero (nonzero) exit status.An arbitrary number of new-lines may appear in alist, instead of semicolons, to delimit commands..PPA command is either a simple command or one of the following.Unless otherwise stated,the value returned by a command is that of thelast simple command executed in the command..TP\fBfor\fP \fIname\fP [ \fBin\fP \fIword...\fP ] \fBdo\fP \fIlist\fP \fBdone\fP.NXR "for command (System V)"Each time a.B forcommand is executed,.I name\^is set to the next.I word\^taken from the.B in.I word\^list.If.BI in " word\^"\&.\|.\|.is omitted, thenthe.B forcommand executes the \fBdo\fP \fIlist\^\fPonce for each positional parameter that is set.For further information, see.B Parameter Substitutionbelow.Execution ends when there are no more words in the list..TP\fBcase\fP \fIword\fP \fBin\fP [ \fIpattern\fP [ | \fIpattern\fP ] ...) \fIlist\fP ;; ] ... \fBesac\fP.NXR "case command (System V)".B casecommand executes the.I list\^associated with the first.I pattern\^that matches.IR word .The form of the patterns isthe same as that used forfile-name generation except that a slash, a leading dot, or a dot immediatelyfollowing a slash need not be matched explicitly.For further information, see.B File Name Generation. .TP\fBif\fP \fIlist\fP \fBthen\fP \fIlist\fP [ \fBelif\fP \fIlist\fP \fBthen\fP \fIlist\fP ] ... [ \fBelse\fP \fIlist\fP ] \fBfi\fP.NXR "if command (System V)"The.I list\^following \fBif\fP is executed and,if itreturns a zero exit status, the.I list\^followingthe first.B thenis executed.Otherwise, the.I list\^following \fBelif\fPis executed and, if its value is zero,the.I list\^followingthe next.B thenis executed.Failing that, the.B else.I list\^is executed.If no.B else.I list\^or.B then.I list\^is executed, then the.B ifcommand returns a zero exit status..TP\fBwhile\fP \fIlist\^\fP \fBdo\fP \fIlist\^\fP \fBdone\fP.NXR "while command (SystemV)"A.B whilecommand repeatedly executes the.B while.I list\^and, if the exit status of the last command in the list is zero, executesthe.B do.IR list .Otherwise the loop terminates.If no commands in the.B do.I list\^are executed, then the.B whilecommand returns a zero exit status.The .B untilcommand may be used in place of.B whileto negatethe loop termination test..TP(\fIlist\^\fP)Execute.I list\^in a sub-shell..TP{\fIlist\^\fP;}Simply executes.I list\^from current shell..TP\fIname\^\fP () {\fIlist\^\fP\;}Define a functionwhich is referenced by.I name\^.The body of the functionis the.I list\^of commands between.BR { " and " } "."Execution of functions is described below. For further information, see.B Execution..PD.PPThe following wordsare only recognized as the first word of a command and when not quoted:.if t .RS.PP.B.if n if then else elif fi case esac for while until do done { }.if t if then else elif f\&i case esac for while until do done { }.if t .RE.SS Comments.NXR "sh5 command interpreter" "comments"A word beginning with.B #causes that word and all the following characters up to a new-lineto be ignored..SS Command Substitution.NXR "sh5 command interpreter" "command substitution"The standard output from a command enclosed ina pair of grave accents .br( \(ga\fIcommand\fP\(ga ) may be used as part or all of a word.Trailing new-lines are removed..SS Parameter Substitution.NXR "sh5 command interpreter" "parameter substitution"The character.B $is used to introduce substitutable parameters.There are two types of parameters,positional and keyword.If parameter is a digit, it is a positional parameter.Positional parameters may be assigned values by.BR set .Keyword parameters (also known as variables)may be assigned values by writing:.EXname = value [ name = value ] ....EE.PPPattern-matching is not performed on value.There cannot be a function and a variable with the same name..PP.PD 0.TP\fB${\fP\fIparameter\^\fP\fB}\fPThe value, if any, of the parameter is substituted.The braces are required only when.I parameter\^is followed by a letter, digit, or underscorethat is not to be interpreted as part of its name.If.I parameter\^is.B \(**or.BR @ ,all the positionalparameters, starting with.BR $1 ,are substituted(separated by spaces).Parameter.B $0is set from argument zero when the shellis invoked..TP\fB${\fP\fIparameter\^\fP\fB:\-\fP\fIword\^\fP\fB}\fPIf.I parameter\^is set and is non-null, substitute its value.Otherwise substitute.IR word ..TP\fB${\fP\fIparameter\^\fP\fB:=\fP\fIword\^\fP\fB}\fPIf.I parameter\^is not set or is nullset it to.IR word .The value of the parameter is substituted.Positional parameters may not be assigned toin this way..TP\fB${\fP\fIparameter\^\fP\fB:?\fP\fIword\^\fP\fB}\fPIf.I parameter\^is set and is non-null, substitute its value;otherwise, print.I word\^and exit from the shell.If.I word\^is omitted, the message``parameter null or not set''is printed..TP\fB${\fP\fIparameter\^\fP\fB:+\fP\fIword\^\fP\fB}\fPIf.I parameter\^is set and is non-null, substitute.IR word ;otherwise substitute nothing..PD.PPIn the above,.I word\^is not evaluated unless it isto be used as the substituted string,so that, in the following example,.B pwdis executed only if.B dis not set or is null:.EXecho ${d:\-`pwd`}.EE.PPIf the colon.RB ( : )is omitted from the above expressions, theshell only checks whether .I parameter\^is set or not..PPThe followingparametersare automatically set by the shell:.RS.PD 0.TP.B #The number of positional parameters in decimal..TP.B \-Flags supplied to the shell on invocation or bythe.B setcommand..TP.B ?The decimal value returned by the last synchronously executed command..TP.B $The process number of this shell..TP.B !The process number of the last background command invoked..PD.RE.PPThe followingparametersare used by the shell:.RS.PD 0.TP.B.SM LOGNAMEThe name of the user's login account, corresponding to the login namein the user database..TP.B.SM HOMEThe default argument (home directory) for the.MS cd 1command..TP.B.SM PATHThe search path for commands. For further information, see.B Executionbelow.The user may not change.B \s-1PATH\s+1if executing under.PN rsh5 ..TP.B.SM CDPATHThe search path for the.MS cd 1command..TP.B.SM MAILIf this parameter is set to the name of a mail fileand the .B \s-1MAILPATH\s+1parameter is not set, the shell informs the user of the arrival of mail in the specified file..TP.B.SM MAILCHECKThis parameter specifies how often (in seconds) the shellwill check for the arrival of mail in the files specified by the.B \s-1MAILPATH\s+1or.B \s-1MAIL\s+1parameters.The default value is 600 seconds (10 minutes).If set to 0, the shell will check before each prompt..TP.B.SM MAILPATHA colon .RB ( : )separated list of file names.If this parameter is set, the shell informs the user of the arrival of mailin any of the specified files. Each file name can be followed by .B %and a message that will be printed when the modification time changes.The default message is.B you have mail..TP.SM.B PS1Primary prompt string, by default.RB `` "$ \|" ''..TP.SM.B PS2Secondary prompt string, by default.RB `` "> \|" ''..TP.SM.B IFS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -