?? sh.1
字號:
.ds OK [\|.ds CK \|].ds LT \s-2<\s0.ds GT \s-2>\s0.ds LE \s-2<\s0.ds ST *.TH SH 1.SH NAMEsh,for,case,if,while,.BR : ,.BR . ,break,continue,cd,eval,exec,exit,export,login,newgrp,read,readonly,set,shift,times,trap,umask,wait\- command language.SH SYNOPSIS.B sh[.B \-ceiknrstuvx] [ arg ] ....SH DESCRIPTION.I Shis a command programming languagethat executes commands read from a terminalor a file.See.B invocationfor the meaning of arguments to the shell..PP.B Commands..brA.I simple-commandis a sequence of non blank.I wordsseparated by blanks (a blank is a.B tabor a.BR space ).The first word specifies the name of the command tobe executed.Except as specified belowthe remaining words are passed as argumentsto the invoked command.The command name is passed as argument 0(see.IR exec (2)).The.I valueof a simple-command is its exit statusif it terminates normally or 200+\fIstatus\fP ifit terminates abnormally (see.IR signal (2)for a list ofstatus values)..LPA.I pipelineis a sequence of one or more.I commandsseparated by.B \(or.The standard output of each command but the lastis connected by a.IR pipe (2)to the standard input of the next command.Each command is run as a separate process;the shell waits for the last command to terminate..LPA.I listis a sequence of one or more.I pipelinesseparated by.BR ; ,.BR & ,.B &&or.B \(or\|\(orand optionally terminated by.B ;or.BR & ..B ;and.B &have equal precedencewhich is lower than that of.B &&and.BR \(or\|\(or ,.B &&and.B \(or\|\(oralso have equal precedence.A semicolon causes sequential execution; an ampersand causesthe preceding.I pipelineto be executed without waiting for it to finish.The symbol.B &&.RB ( \(or\|\(or )causes the.I listfollowing to be executed only if the preceding.I pipelinereturns a zero (non zero) value.Newlines may appear in a.I list,instead of semicolons,to delimit commands..LPA.I commandis either a simple-commandor one of the following.The value returned by a command is that of thelast simple-command executed in the command..TP\fBfor \fIname\fR \*(OK\fBin \fIword\fR ...\*(CK \fBdo \fIlist \fBdone\fREach time a.B forcommand is executed.I nameis set to the next word in the.B forword listIf.BI in \ word\&...is omitted then.Bin "$@"is assumed.Execution ends when there are no more words in the list..TP\fBcase \fIword \fBin\fR \*(OK\fIpattern \fR\*(OK \fB\(or \fIpattern \fR\*(CK ... \fB) \fIlist \fB;;\fR\*(CK ... \fBesac\fRA.B casecommand executes the.I listassociated with the firstpattern that matches.I word.The form of the patterns isthe same as that used forfile name generation..TP\fBif \fIlist \fBthen \fIlist\fR \*(OK\fBelif \fIlist \fBthen \fIlist\fR\*(CK ... \*(OK\fBelse \fIlist\fR\*(CK \fBfi\fRThe.I listfollowing.B ifis executed and if it returns zero the.I listfollowing.B thenis executed.Otherwise, the.I listfollowing.B elifis executed and if its value is zerothe.I listfollowing.B thenis executed.Failing that the.B else.I listis executed..TP\fBwhile \fIlist\fR \*(OK\fBdo \fIlist\fR\*(CK \fBdone\fRA.B whilecommand repeatedly executes the.B while.I listand if its value is zero executes the.B do.I list;otherwise the loop terminates.The value returned by a.B whilecommand is thatof the last executed command in the.B do.I list..B untilmay be used in place of.B whileto negatethe loop termination test..TP.BI ( " list " )Execute.I listin a subshell..TP.BI { " list " }.I listis simply executed..LPThe following wordsare only recognized as the first word of a commandand when not quoted..IP.Bif then else elif fi case in esac for while until do done { }.PP.B Command substitution..brThe standard output from a command enclosed ina pair of grave accents.RB ( \`\|\` )may be used as part or allof a word;trailing newlines are removed..PP.B Parameter substitution..brThe character.B $is used to introduce substitutableparameters.Positional parameters may be assigned values by.BR set .Variables may be set by writing.IP.IB name = value[.IB name = value] ....TP$\fB\|{\fIparameter\fB\|}\fRA.I parameteris a sequence of letters, digits or underscores (a.IR name ),a digit,or any of the characters.B* @ # ? \- $ !\|.The value, if any, of the parameter is substituted.The braces are required only when.I parameteris followed by a letter, digit, or underscorethat is not to be interpreted as part of its name.If.I parameteris a digit then it is a positional parameter.If.I parameteris.BR * " or" " @"then all the positionalparameters, starting with.SM.BR $1 ,are substitutedseparated by spaces..SM.B $0is set from argument zero when the shellis invoked..TP$\fB\|{\fIparameter\|\-word\|\fB}\fRIf.I parameteris set then substitute its value;otherwise substitute.I word..TP$\fB\|{\fIparameter\|\(eq\|word\|\fB}\fRIf.I parameteris not set then set it to.I word;the value of the parameter is then substituted.Positional parameters may not be assigned toin this way..TP$\fB\|{\fIparameter\|?\|word\|\fB}\fRIf.I parameteris set then substitute its value;otherwise, print.I wordand exit from the shell.If.I wordis omitted then a standard message is printed..TP$\fB\|{\fIparameter\|\(plword\|\fB}\fRIf.I parameteris set then substitute.I word;otherwise substitute nothing..LPIn the above.I wordis not evaluated unless it isto be used as the substituted string.(So that, for example,echo ${d\-\`pwd\`}will only execute.I pwdif.I dis unset.).LPThe following.I parametersare automatically set by the shell..RS.TP.B #The number of positional parameters in decimal..PD 0.TP.B \-Options supplied to the shell on invocation or by.BR set ..TP.B ?The value returned by the last executed commandin decimal..TP.B $The process number of this shell..TP.B !The process number of the last background command invoked..PD.RE.LPThe following.I parametersare used but not set by the shell..RS.TP.B.SM HOMEThe default argument (home directory) for the.B cdcommand..PD 0.TP.B.SM PATHThe search path for commands (see.BR execution )..TP.B.SM MAILIf this variable is set to the name ofa mail file then the shell informs the user ofthe arrival of mail in the specified file..SM.TP.B PS1Primary prompt string, by default `$ '..TP.SM.B PS2Secondary prompt string, by default `> '..TP.SM.B IFSInternal field separators,normally.BR space ,.BR tab ,and.BR newline ..PD.RE.PP.B Blank interpretation..brAfter parameter and command substitution,any results of substitution are scanned for internal field separatorcharacters (those found in.SM.BR $IFS \*S)and split into distinct arguments where such characters are found.Explicit null arguments ("" or \'\') are retained.Implicit null arguments(those resulting from.I parametersthat have no values) are removed..PP.B File name generation..brFollowing substitution, each command word is scanned forthe characters.BR * ,.B ?and.B \*(OK.If one of these characters appearsthen the word is regarded as a pattern.The word is replaced with alphabetically sorted file names that match the pattern.If no file name is found that matches the pattern thenthe word is left unchanged.The character.B .at the start of a file nameor immediately following a.BR / ,and the character.BR / ,must be matched explicitly..TP .B \*(STMatches any string, including the null string..PD 0.TP .B ?Matches any single character..TP .B \*(OK...\*(CKMatches any one of the charactersenclosed.A pair of characters separated by.B \-matches anycharacter lexically between the pair..PD.PP.B Quoting..brThe following characters have a special meaning to the shelland cause termination of a word unless quoted..LP \fB; & ( ) \(or \*(LT \*(GT newline space tab\fP.LPA character may be.I quotedby precedingit with a.B\\\|..B \\\\newlineis ignored.All characters enclosed between a pair of quote marks (\fB\'\|\'\fP),except a single quote,are quoted.Inside double quotes(\fB"\|"\fP)parameter and command substitution occurs and.B\\quotes the characters.B\\ \` "and.BR $ \|..LP.B"$*"is equivalent to.SM.B"$1 $2 ..."whereas.br.B"$@"is equivalent to.SM.B"$1" "$2" ... ..PP.B Prompting..br
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -