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

📄 unx12.htm

📁 Linux Unix揭密.高质量电子书籍.对学习Linux有大帮助,欢迎下载学习.
💻 HTM
📖 第 1 页 / 共 5 页
字号:

<TD>

<P>The equivalent option name is monitor. -m runs commands that you launch in the background&#151;using the &amp; shell operator&#151;in a separate process group, automatically reports the termination of such background jobs, and enables use of the jobs 
command for managing background jobs. If -m is not set, commands launched with the &amp; operator execute in the same manner as with the Bourne shell, and job control is not in effect. The default is to enable this option automatically for interactive 
shells.</P>

<TR>

<TD>

<P>-n</P>

<TD>

<P>The equivalent option name is noexec. -n causes the shell to read and process commands but not execute them. You can use this option in the form ksh -n shell-script-filename to check the syntax of a shell script. You'll probably not want to use this 
option with your login shell.</P>

<TR>

<TD>

<P>-p</P>

<TD>

<P>The equivalent option name is privileged. The -p option is useful for script writers. A shell script file that has the set-uid bit, the set-gid bit, or both will, when invoked by the Korn shell, have the effective user-id and effective group-id set 
according to the file permissions, the owner-id, and the group-id; and the -p option will be on. In this mode, the shell script enjoys the permissions of the effective user-id and group-id, not those of the real user. Setting the -p option off&#151;for 
example, with set +p&#151;causes the Korn shell to set the effective user-id and group-id to those of the real user, effectively switching to the user's&#151;not the file's&#151;permissions. You can subsequently use the set -p command to revert to 
privileged mode. Not all versions of the Korn shell support this definition of the -p option; only the more recent UNIX operating system releases include this facility.</P>

<TR>

<TD>

<P>-s</P>

<TD>

<P>When used on the set command, -s sorts the arg command arguments into alphabetical sequence before storing. Used on the ksh command, the -s option has the different meaning described earlier.</P>

<TR>

<TD>

<P>-t</P>

<TD>

<P>The Korn shell, invoked with this option, reads and executes one command and then exits. You should set the -t option on the ksh command, not with the set command.</P>

<TR>

<TD>

<P>-u</P>

<TD>

<P>The equivalent option name is nounset. -u causes the shell to generate an error message for a reference to an unset variable&#151;for example, referring to $house when no value has previously been assigned to house. The default behavior is to replace 
the variable reference with the null string. This option is useful to script writers for debugging shell scripts.</P>

<TR>

<TD>

<P>-v</P>

<TD>

<P>The equivalent option name is verbose. Each command is printed before scanning, substitution, and execution occur. This is useful for testing shell scripts when used in the form ksh -v shell-script-filename, or with set -v and set +v from within a shell 

script to force the display of a range of commands as they are being executed.</P>

<TR>

<TD>

<P>-x</P>

<TD>

<P>The equivalent option name is xtrace. -x causes the Korn shell to display each command after scanning and substitution but before execution. Each line is prefixed with the expanded value of the PS4 variable. Using this option enables you to see the 
effects of variable and command substitution on the command line. Used in the form ksh -x shell-script-filename, the -x option is a handy debugging tool for script writers.</P>

<TR>

<TD>

<P>&#151;</P>

<TD>

<P>Used on either the ksh or set command, this option forces interpretation of the remaining words of the command line as arguments&#151;not options&#151;even for words beginning with - or +. The &#151; option is often used on the set command for setting 
new values for the positional parameters, because it ensures that no substituted values are construed as set statement options.</P></TABLE>

<P>In addition to the previous letter options, the -o keyletter supports the following additional named options:

<BR></P>

<TABLE BORDER>

<TR>

<TD>

<P>

<BR>bgnice

<BR></P>

<TD>

<P>

<BR>Requests the shell automatically to reduce the priority of background jobs initiated with the &amp; shell operator, as though the nice command had been used.

<BR></P>

<TR>

<TD>

<P>

<BR>EMACS

<BR></P>

<TD>

<P>

<BR>Invokes the EMACS editing mode. It is reset with set +o EMACS or set -o vi.

<BR></P>

<TR>

<TD>

<P>

<BR>gmacs

<BR></P>

<TD>

<P>

<BR>Invokes the EMACS editing mode with the alternate definition of the Ctrl-t transpose function.

<BR></P>

<TR>

<TD>

<P>

<BR>ignoreeof

<BR></P>

<TD>

<P>

<BR>Requests the shell to ignore an end of file character entered at the beginning of the command line. Ordinarily an EOF character entered in this position causes the shell to terminate. To avoid accidentally terminating the shell, you can set this 
option. You must use the exit command to terminate the shell and log out.

<BR></P>

<TR>

<TD>

<P>

<BR>markdirs

<BR></P>

<TD>

<P>

<BR>Causes wildcard expansion to append a slash (/) to any generated pathnames that are the pathnames of directories.

<BR></P>

<TR>

<TD>

<P>

<BR>noclobber

<BR></P>

<TD>

<P>

<BR>Modifies the behavior of the &gt; redirection operator to inhibit the overwriting of existing files. If you name an existing file after &gt;, the shell writes an error message and doesn't open the output file. Use &gt;| to redirect output to an 
existing file when noclobber is set.

<BR></P>

<TR>

<TD>

<P>

<BR>nolog

<BR></P>

<TD>

<P>

<BR>Inhibits the storing of functions in your command history file.

<BR></P>

<TR>

<TD>

<P>

<BR>vi

<BR></P>

<TD>

<P>

<BR>Enables the vi editing mode with line input. Line input provides only a subset of the features of vi command editing, but it provides better performance than option viraw. You reset vi editing mode with set +o vi or set -o EMACS.

<BR></P>

<TR>

<TD>

<P>

<BR>viraw

<BR></P>

<TD>

<P>

<BR>Enables vi editing mode with character input. Character input provides all the features of the vi editing mode but with more overhead than option vi.</P></TABLE>

<BR>

<P>The -A option can be used on either the ksh command line or the set command to define an array variable with initial values. When you specify -A, the next argument must be the name of the array variable to be initialized. Subsequent arguments are stored 

as consecutive elements of the array beginning with element 0. The -A option resets any previous value of the array variable before it assigns new values. Thus, the ending value of the array consists of only those arguments specified as arg.

<BR></P>

<P>The +A option assigns the arg values successively starting with element 0, but it doesn't reset any previous value of the array. Thus, if the array variable previously had twelve values and only six values were provided with +A, after execution the 
first six elements of the array would be the arg values and the last six elements would be left over from the previous value of the array.

<BR></P>

<P>The significance of the arg values depends on the options specified. If option -A is specified, the values are taken as initial array element values. If option -s or -i is specified, or if option -i defaults because the shell input is a terminal, the 
arg values are used to initialize the positional parameters $1, $2, and so on. If option -c is specified, the first arg is taken as a command string to be executed. If none of the options -A, -c, -i, or -s is specified, the first arg is taken as the name 
of a file of shell commands to be executed, and subsequent arg values are temporarily set as the positional parameters $1, $2, and so on, during the file's execution.

<BR></P>

<H3 ALIGN="CENTER">

<CENTER><A ID="I17" NAME="I17">

<FONT SIZE=4><B>Command History</B>

<BR></FONT></A></CENTER></H3>

<P>Command history and command editing are somewhat interrelated features. To employ fully all the benefits of command editing, however, you need an understanding of how command history works.

<BR></P>

<P>Command History is simply the automatic recording of commands that you enter in a numbered list. The list is kept in a special disk file in your home directory to preserve it from login session to session. Therefore, when you log in, the command history 

list from your previous session is available for reference and use. New commands you enter are added to the end of the list. To keep the list from growing overly large, the oldest commands at the beginning of the list are deleted when the list grows to a 
certain fixed size.

<BR></P>

<P>You don't need to do anything to activate the command history feature, nor do you need to specify its maximum size. Its operation is completely automatic. Your only mission, should you decide to accept it, is to use the list to make your life easier.

<BR></P>

<P>You can use the command history list in one of three ways. You can view the commands in the history list, using the history command. Use the history command when you can't remember whether you've already performed an action or if you want to refer to 
the syntax or operands of a previous command. You can resubmit a command from the list, using the r command. Except for very short commands, it's faster to resubmit a command you typed before with the r command than it is to type the command again. The r 
command provides several alternative ways for you to identify which command in the history list you want to reexecute. You can modify a command in the history list and then execute the modified command. You use the fc command to invoke this form of command 

editing. You can use any text editor you like to edit the chosen command. By default, the Korn shell invokes the crusty old ed command for you, but you can change the default to any text editor you want.

<BR></P>

<P>Please note that command editing with the fc command, although a convenient and useful feature of Command History, is not the same as the command editing feature discussed later in this chapter.

<BR></P>

<P>Now take a closer look at these commands for viewing and manipulating command history.

<BR></P>

<H4 ALIGN="CENTER">

<CENTER><A ID="I18" NAME="I18">

<FONT SIZE=3><B>Displaying the Command History List</B>

<BR></FONT></A></CENTER></H4>

<P>The command history command displays the commands in the command history list. Each command is listed with a line number preceding it. The line number uniquely identifies each command in the history list, and it is one way in which you can refer to a 
specific line in the history list.

<BR></P>

<PRE>$ history

⌨️ 快捷键说明

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