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

📄 ch11.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 4 页
字号:


<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->






 











 

















<H1></H1>







<UL>



	<LI><A HREF="#Heading1">- 11 -</A>



	<UL>



		<LI><A HREF="#Heading2">pdksh</A>



		<UL>



			<LI><A HREF="#Heading3">The Public Domain Korn Shell (pdksh)</A>



			<LI><A HREF="#Heading4">NOTE</A>



			<UL>



				<LI><A HREF="#Heading5">Command-Line Completion</A>



			</UL>



			<LI><A HREF="#Heading6">NOTE</A>



			<LI><A HREF="#Heading7">NOTE</A>



			<UL>



				<LI><A HREF="#Heading8">Wildcards</A>



				<LI><A HREF="#Heading9">Command History</A>



			</UL>



			<LI><A HREF="#Heading10">NOTE</A>



			<LI><A HREF="#Heading11">NOTE</A>



			<LI><A HREF="#Heading12">TIP</A>



			<UL>



				<LI><A HREF="#Heading13">Aliases</A>



			</UL>



			<LI><A HREF="#Heading14">NOTE</A>



			<UL>



				<LI><A HREF="#Heading15">Input Redirection</A>



				<LI><A HREF="#Heading16">Output Redirection</A>



				<LI><A HREF="#Heading17">Pipelines</A>



			</UL>



			<LI><A HREF="#Heading18">Shell Prompts</A>



			<LI><A HREF="#Heading19">Job Control</A>



			<LI><A HREF="#Heading20">Key Bindings</A>



			<LI><A HREF="#Heading21">Customizing Your pdksh</A>



			<LI><A HREF="#Heading22">TIP</A>



			<LI><A HREF="#Heading23">Listing 11.1.</A>



			<LI><A HREF="#Heading24">Default ksh.kshrc file.</A>



			<LI><A HREF="#Heading25">pdksh Commands</A>



			<LI><A HREF="#Heading26">pdksh Variables</A>



			<LI><A HREF="#Heading27">Summary</A>



		</UL>



	</UL>



</UL>







<P>



<HR SIZE="4">







<H2 ALIGN="CENTER"><A NAME="Heading1<FONT COLOR="#000077">- 11 -</FONT></H2>



<H2 ALIGN="CENTER"><A NAME="Heading2<FONT COLOR="#000077">pdksh</FONT></H2>



<P><I>by Rick McMullin</I></P>







<P>IN THIS CHAPTER</P>







<UL>



	<LI>The Public Domain Korn Shell (pdksh) 



	<P>



	<LI>Shell Prompts 



	<P>



	<LI>Job Control 



	<P>



	<LI>Key Bindings 



	<P>



	<LI>Customizing Your pdksh



	<P>



	<LI>pdksh Commands 



	<P>



	<LI>pdksh Variables 



</UL>







<P><BR>



In the preceding chapter, you saw the Bourne Again Shell (<TT>bash</TT>) in some



detail. Not everyone wants to use the <TT>bash</TT> shell, so several other shells



are included with most Linux systems. One of them is <TT>pdksh</TT>, a variation



on the Korn Shell.</P>







<P>In this chapter, we look at the <TT>pdksh</TT> shell and how it can be efficiently



used. After reading this chapter, you will be familiar with the following topics:







<UL>



	<LI>Command-line completion and wildcards



	<P>



	<LI>Command history and aliases



	<P>



	<LI>Input and output redirection



	<P>



	<LI>Pipelines



	<P>



	<LI>How to change your shell prompt



	<P>



	<LI>Job control



	<P>



	<LI>Key bindings



</UL>







<P>We will also look at how you can customize your copy of <TT>pdksh</TT>, as well



as several of the important commands and variables used by the shell.



<H3 ALIGN="CENTER"><A NAME="Heading3<FONT COLOR="#000077">The Public Domain



Korn Shell (pdksh)</FONT></H3>



<P>The Korn shell, written by David Korn, was the third mainstream shell written



for UNIX. Because of this, it incorporated many of the features of the Bourne and



C shells (which were the first two shells). Because of the Korn shell's popularity



among UNIX users, a version was developed for Linux called the Public Domain Korn



Shell, or <TT>pdksh</TT>.</P>



<P>The current version of the Public Domain Korn Shell does not support all of the



features that exist in the commercial version of the Korn shell. It does support



most of the main features, however, and adds a few new features of its own.







<DL>



	<DT></DT>



</DL>











<DL>



	<DD>



<HR>



<A NAME="Heading4<FONT COLOR="#000077"><B>NOTE: </B></FONT>One place you can



	obtain <TT>pdksh</TT> is from the site <TT>ftp://cs.mun.ca/pub/pdksh</TT>.



<HR>







</DL>







<H4 ALIGN="CENTER"><A NAME="Heading5<FONT COLOR="#000077">Command-Line Completion</FONT></H4>



<P>Often, when you are entering commands at the command line, the complete text of



the command is not necessary in order for <TT>pdksh</TT> to be able to determine



what you want to do. Command-line completion enables you to type in a partial command,



and then by entering a key sequence, tell <TT>pdksh</TT> to try to finish the command



for you.</P>



<P><TT>pdksh</TT> does not default to allowing the user to perform command-line completion.



You must enter a command to tell <TT>pdksh</TT> that you want to be able to use command-line



completion. In order to enable command-line completion, enter one of the following



commands:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">set -o emacs



set -o vi



</FONT></PRE>



<P>This causes <TT>pdksh</TT> to accept command editing that is similar to <TT>emacs</TT>



or <TT>vi</TT>. Choose the editor that you are most familiar with, and use the basic



editor commands for command-line editing.







<DL>



	<DT></DT>



</DL>











<DL>



	<DD>



<HR>



<A NAME="Heading6<FONT COLOR="#000077"><B>NOTE:</B> </FONT>Most people find



	the <TT>emacs</TT> editing mode more user-friendly than the <TT>vi</TT> editing mode.



	When using <TT>vi</TT> command-line editing, you must be in command mode when you



	enter any of the editing commands. You can enter command mode by pressing the Esc



	key. When command mode has been entered, you cannot type any characters onto the



	command line until you enter edit mode. There are many ways of doing this, but the



	usual way is by pressing the i (insert) key.



<HR>







</DL>







<P>After the command-line completion function has been enabled, you can perform command-line



completion by pressing the Esc key twice (when using <TT>emacs</TT> command-line



editing), or by pressing \ (when using <TT>vi</TT> command-line editing). For example,



if your current directory contains the files<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">News/         bin/         games/       mail/         sample.text        test/



</FONT></PRE>



<P>and you want to edit the file <TT>sample.text</TT> using the <TT>vi</TT> text



editor, you could enter the following command:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">vi sample.text



</FONT></PRE>



<P>After the <TT>s</TT> is typed, the only file that you could be referring to is



<TT>sample.text</TT>, because it is the only file in the current directory that begins



with the letter s. To get <TT>pdksh</TT> to finish the command when you are using



<TT>emacs</TT>-style command editing, you must press the Esc key twice after you



type the letter s:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">vi s&lt;escape&gt;&lt;escape&gt;



</FONT></PRE>



<P>To get <TT>pdksh</TT> to finish the command when you are using <TT>vi</TT> command



editing, you must press the \ key after you type the letter <TT>s</TT>:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">vi s\



</FONT></PRE>



<P>Either of these commands causes <TT>pdksh</TT> to finish the line for you and



display the result on the screen. The command does not execute until you press the



Enter key. This is done to give you a chance to confirm that the command <TT>pdksh</TT>



came up with is the command that you really intended.</P>



<P>If the <TT>sample.text</TT> file is not the only file in the directory that begins



with the letter <TT>s</TT>, <TT>pdksh</TT> completes the command as far as it can



and then beeps, indicating that it needs more information to complete the command.







<DL>



	<DT></DT>



</DL>











<DL>



	<DD>



<HR>



<A NAME="Heading7<FONT COLOR="#000077"><B>NOTE: </B></FONT>The keyboard equivalent



	of pressing the Esc key is Ctrl-[, usually written as <TT>^[</TT>. The caret (<TT>^</TT>)



	is the abbreviation for the Ctrl key. Pressing Esc twice using the Ctrl-[ sequence



	would be written as <TT>^[^[</TT>. You might see this convention in books or man



	pages.



<HR>







</DL>







<H4 ALIGN="CENTER"><A NAME="Heading8<FONT COLOR="#000077">Wildcards</FONT></H4>



<P>The <TT>pdksh</TT> shell makes typing commands easier by enabling the user to



use wildcards. <TT>pdksh</TT> supports the same wildcards that <TT>bash</TT> does:



<TT>*</TT> matches any character and any number of characters.</P>



<P><TT>?</TT> matches any single character.











<BLOCKQUOTE>



	<P><TT>[...]</TT> matches any single character contained within the brackets.







</BLOCKQUOTE>







<P>The <TT>*</TT> wildcard can be used in a way that is similar to command-line completion.



For example, if the current directory contains the files<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">News/         bin/         games/       mail/         sample.text        test/



</FONT></PRE>



<P>and you want to edit the <TT>sample.text</TT> file using the <TT>vi</TT> text



editor, you can perform this task by using the following wildcard:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">vi s*



</FONT></PRE>



<P>The <TT>*</TT> matches any character (and any number of characters), so <TT>pdksh</TT>

⌨️ 快捷键说明

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