⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ksh.man

📁 一个开放源代码的 AT&T 的 Korn Shell 的复制品, 支持大多数 ksh89 的特性。
💻 MAN
📖 第 1 页 / 共 5 页
字号:
for commands and \fB.\fP'd files.An empty string resulting from a leading or trailing colon, or two adjacentcolons is treated as a `.', the current directory..\"}}}.\"{{{  POSIXLY_CORRECT.IP \fBPOSIXLY_CORRECT\fPIf set, this parameter causes the \fBposix\fP option to be enabled.See POSIX Mode below..\"}}}.\"{{{  PPID.IP \fBPPID\fPThe process ID of the shell's parent (readonly)..\"}}}.\"{{{  PS1.IP \fBPS1\fP\fBPS1\fP is the primary prompt for interactive shells..ksh(Parameter, command and arithmetic substitutions are performed, and\fB!\fP is replaced with the current command number (see \fBfc\fPcommand below).  A literal ! can be put in the prompt by placing !! in PS1.Note that since the command line editors try to figure out how long theprompt is (so they know how far it is to edge of the screen),escape codes in the prompt tend to mess things up.You can tell the shell not to count certain sequences (such as escape codes)by prefixing your prompt with a non-printing character (such as control-A)followed by a carriage return and then delimiting the escape codes withthis non-printing character.If you don't have any non-printing characters, you're out of luck...BTW, don't blame me for this hack; it's in the original ksh..ksh).sh(The prompt is printed verbatim (\fIi.e.\fP, no substitutions are done)..sh)Default is `\fB$\ \fP' for non-root users, `\fB#\ \fP' for root...\"}}}.\"{{{  PS2.IP \fBPS2\fPSecondary prompt string, by default `\fB>\fP ', used when more input isneeded to complete a command..\"}}}.\"{{{  PS3.ksh(.IP \fBPS3\fPPrompt used by \fBselect\fP statement when reading a menu selection.Default is `\fB#?\ \fP'..ksh).\"}}}.\"{{{  PS4.IP \fBPS4\fPUsed to prefix commands that are printed during execution tracing(see \fBset \-x\fP command below)..ksh(Parameter, command and arithmetic substitutions are performedbefore it is printed..ksh).sh(The prompt is printed verbatim (\fIi.e.\fP, no substitutions are done)..sh)Default is `\fB+\ \fP'..\"}}}.\"{{{  PWD.IP \fBPWD\fPThe current working directory.  Maybe unset or null if shell doesn'tknow where it is..\"}}}.\"{{{  RANDOM.ksh(.IP \fBRANDOM\fPA simple random number generator.  Every time \fBRANDOM\fP isreferenced, it is assigned the next number in a random number series.The point in the series can be set by assigning a number to\fBRANDOM\fP (see \fIrand\fP(3))..ksh).\"}}}.\"{{{  REPLY.IP \fBREPLY\fPDefault parameter for the \fBread\fP command if no names are given.Also used in \fBselect\fP loops to store the value that is read fromstandard input..\"}}}.\"{{{  SECONDS.ksh(.IP \fBSECONDS\fPThe number of seconds since the shell started or, if the parameter has beenassigned an integer value, the number of seconds since the assignment plusthe value that was assigned..ksh).\"}}}.\"{{{  TMOUT.ksh(.IP \fBTMOUT\fPIf set to a positive integer in an interactive shell, it specifiesthe maximum number of seconds the shell will wait for input afterprinting the primary prompt (\fBPS1\fP).  If the time is exceeded, theshell exits..ksh).\"}}}.\"{{{  TMPDIR.IP \fBTMPDIR\fPThe directory shell temporary files are created in.  If this parameteris not set, or does not contain the absolute path of a writabledirectory, temporary files are created in \fB/tmp\fP..\"}}}.\"{{{  VISUAL.ksh(.IP \fBVISUAL\fPIf set, this parameter controls the command line editing mode forinteractive shells.  If the last component of the path specified in thisparameter contains the string \fBvi\fP, \fBemacs\fP or \fBgmacs\fP, thevi, emacs or gmacs (Gosling emacs) editing mode is enabled, respectively..ksh).\"}}}.\"}}}.\"}}}.\"{{{  Tilde Expansion.SS "Tilde Expansion"Tilde expansion, which is done in parallel with parameter substitution,is done on words starting with an unquoted \fB~\fP.  The charactersfollowing the tilde, up to the first \fB/\fP, if any, are assumed to bea login name.  If the login name is empty, \fB+\fP or \fB\-\fP, thevalue of the \fBHOME\fP, \fBPWD\fP, or \fBOLDPWD\fP parameter issubstituted, respectively.  Otherwise, the password file is searched forthe login name, and the tilde expression is substituted with theuser's home directory.  If the login name is not found in the passwordfile or if any quoting or parameter substitution occurs in the login name,no substitution is performed..PPIn parameter assignments (those preceding a simple-command or thoseoccurring in the arguments of \fBalias\fP, \fBexport\fP, \fBreadonly\fP,and \fBtypeset\fP), tilde expansion is done after any unquoted colon(\fB:\fP), and login names are also delimited by colons..PPThe home directory of previously expanded login names are cached andre-used.  The \fBalias \-d\fP command may be used to list, change andadd to this cache (\fIe.g.\fP, `alias \-d fac=/usr/local/facilities; cd~fac/bin')..\"}}}.\"{{{  Brace Expansion.ksh(.SS "Brace Expansion (alternation)"Brace expressions, which take the form.RS\fIprefix\fP\fB{\fP\fIstr\fP1\fB,\fP...\fB,\fP\fIstr\fPN\fB}\fP\fIsuffix\fP.REare expanded to N words, each of which is the concatenation of\fIprefix\fP, \fIstr\fPi and \fIsuffix\fP(\fIe.g.\fP, `a{c,b{X,Y},d}e' expands to four word: ace, abXe, abYe, and ade).As noted in the example, brace expressions can be nested and the resultingwords are not sorted.Brace expressions must contain an unquoted comma (\fB,\fP) for expansionto occur (\fIi.e.\fP, \fB{}\fP and \fB{foo}\fP are not expanded).Brace expansion is carried out after parameter substitution and beforefile name generation..ksh).\"}}}.\"{{{  File Name Patterns.SS "File Name Patterns".PPA file name pattern is a word containing one or more unquoted \fB?\fP or\fB*\fP characters or \fB[\fP..\fB]\fP sequences.  Once brace expansion hasbeen performed, the shell replaces file name patterns with the sorted namesof all the files that match the pattern (if no files match, the word isleft unchanged).  The pattern elements have the following meaning:.IP \fB?\fPmatches any single character..IP \fB*\fPmatches any sequence of characters..IP \fB[\fP..\fB]\fPmatches any of the characters inside the brackets.  Ranges of characterscan be specified by separating two characters by a \fB\-\fP, \fIe.g.\fP,\fB[a0\-9]\fP matches the letter \fBa\fP or any digit.In order to represent itself, a\fB\-\fP must either be quoted or the first or last character in the characterlist.  Similarly, a \fB]\fP must be quoted or the first character in the listif it is represent itself instead of the end of the list.  Also, a \fB!\fPappearing at the start of the list has special meaning (see below), so torepresent itself it must be quoted or appear later in the list..IP \fB[!\fP..\fB]\fPlike \fB[\fP..\fB]\fP, except it matches any character not inside the brackets..ksh(.IP "\fB*(\fP\fIpattern\fP\fB|\fP ... \fP|\fP\fIpattern\fP\fB)\fP"matches any string of characters that matches zero or more occurancesof the specified patterns.Example: the pattern \fB*(foo|bar)\fP matches the strings`', `foo', `bar', `foobarfoo', \fIetc.\fP..IP "\fB+(\fP\fIpattern\fP\fB|\fP ... \fP|\fP\fIpattern\fP\fB)\fP"matches any string of characters that matches one or more occurancesof the specified patterns.Example: the pattern \fB+(foo|bar)\fP matches the strings`foo', `bar', `foobarfoo', \fIetc.\fP..IP "\fB?(\fP\fIpattern\fP\fB|\fP ... \fP|\fP\fIpattern\fP\fB)\fP"matches the empty string or a string that matches one of thespecified patterns.Example: the pattern \fB?(foo|bar)\fP only matches the strings`', `foo' and `bar'..IP "\fB@(\fP\fIpattern\fP\fB|\fP ... \fP|\fP\fIpattern\fP\fB)\fP"matches a string that matches one of thespecified patterns.Example: the pattern \fB@(foo|bar)\fP only matches the strings`foo' and `bar'..IP "\fB!(\fP\fIpattern\fP\fB|\fP ... \fP|\fP\fIpattern\fP\fB)\fP"matches any string that does not match one of the specifiedpatterns.Examples: the pattern \fB!(foo|bar)\fP matches all strings except`foo' and `bar'; the pattern \fB!(*)\fP matches no strings;the pattern \fB!(?)*\fP matches all strings (think about it)..ksh).PPNote that pdksh currently never matches \fB.\fP and \fB..\fP, but the originalksh, Bourne sh and bash do, so this may have to change (too bad)..PPNote that none of the above pattern elements match either a period (\fB.\fP)at the start of a file name or a slash (\fB/\fP), even if they are explicitlyused in a \fB[\fP..\fB]\fP sequence; also, the names \fB.\fP and \fB..\fPare never matched, even by the pattern \fB.*\fP..PPIf the \fBmarkdirs\fP option is set, any directories that result fromfile name generation are marked with a trailing \fB/\fP..PP.\" todo: implement this ([[:alpha:]], \fIetc.\fP)The POSIX character classes (\fIi.e.\fP,\fB[:\fP\fIclass-name\fP\fB:]\fP inside a \fB[\fP..\fB]\fP expression)are not yet implemented..\"}}}.\"{{{  Input/Output Redirection.SS "Input/Output Redirection"When a command is executed, its standard input, standard output andstandard error (file descriptors 0, 1 and 2, respectively) are normallyinherited from the shell.Three exceptions to this are commands in pipelines, for which standard inputand/or standard output are those set up by the pipeline, asynchronous commandscreated when job control is disabled, for which standard input is initiallyset to be from \fB/dev/null\fP, and commands for which any of the followingredirections have been specified:.IP "\fB>\fP \fIfile\fP"standard output is redirected to \fIfile\fP.  If \fIfile\fP does not exist,it is created; if it does exist, is a regular file and the \fBnoclobber\fPoption is set, an error occurs, otherwise the file is truncated.Note that this means the command \fIcmd < foo > foo\fP will open\fIfoo\fP for reading and then truncate it when it opens it for writing,before \fIcmd\fP gets a chance to actually read \fIfoo\fP..IP "\fB>|\fP \fIfile\fP"same as \fB>\fP, except the file is truncated, even if the \fBnoclobber\fPoption is set..IP "\fB>>\fP \fIfile\fP"same as \fB>\fP, except the file an existing file is appended to insteadof being truncated.  Also, the file is opened in append mode, so writesalways go to the end of the file (see \fIopen\fP(2))..IP "\fB<\fP \fIfile\fP"standard input is redirected from \fIfile\fP, which is opened for reading..IP "\fB<>\fP \fIfile\fP"same as \fB<\fP, except the file is opened for reading and writing..IP "\fB<<\fP \fImarker\fP"after reading the command line containing this kind of redirection (called ahere document), the shell copies lines from the command source into a temporaryfile until a line matching \fImarker\fP is read.When the command is executed, standard input is redirected from the temporaryfile.If \fImarker\fP contains no quoted characters, the contents of thetemporary file are processed as if enclosed in double quotes each timethe command is executed, so parameter, command and arithmetic substitutionsare performed, along with backslash (\fB\e\fP) escapes for\fB$\fP, \fB`\fP, \fB\e\fP and \fB\enewline\fP.If multiple here documents are used on the same command line, they aresaved in order..IP "\fB<<-\fP \fImarker\fP"same as \fB<<\fP, except leading tabs are stripped from lines in thehere document..IP "\fB<&\fP \fIfd\fP"standard input is duplicated from file descriptor \fIfd\fP.\fIfd\fP can be a single digit, indicating the number of an existingfile descriptor, the letter \fBp\fP, indicating the file descriptorassociated with the output of the current co-process, orthe character \fB\-\fP, indicating standard input is to be closed..IP "\fB>&\fP \fIfd\fP"same as \fB<&\fP, except the operation is done on standard output..PPIn any of the above redirections, the file descriptor that is redirected(\fIi.e.\fP, standard input or standard output) can be explicitly given bypreceding the redirection with a single digit.Parameter, command and arithmetic substitutions, tilde substitutions and(if the shell is interactive) file name generation are all performedon the \fIfile\fP, \fImarker\fP and \fIfd\fP arguments of redirections.Note however, that the results of any file name generation are only usedif a single file is matched; if multiple files match, the word with theunexpanded file name generation characters is used.Note that in restricted shells, redirections which can create files cannotbe used..PPFor simple-commands, redirections may appear anywhere in the command, forcompound-commands (\fBif\fP statements, \fIetc.\fP), any redirections mustappear at the end.Redirections are processed after pipelines are created and in the order theyare given, so.RS\fBcat /foo/bar 2>&1 > /dev/null | cat \-n\fP.REwill print an error with a line number prepended to it..\"}}}.\"{{{  Arithmetic Expressions.SS "Arithmetic Expressions"Integer arithmetic expressions can be used.ksh(with the \fBlet\fP command,.ksh)inside \fB$((\fP..\fB))\fP expressions,inside array references (\fIe.g.\fP, \fIname\fP\fB[\fP\fIexpr\fP\fB]\fP),as numeric arguments to the \fBtest\fP command,and as the value of an assignment to an integer parameter..PPExpression may contain alpha-numeric parameter identifiers, arrayreferences, and integer constants and may be combined with thefollowing C operators (listed and grouped in increasing order of precedence).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -