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

📄 ch01_08.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 1] 1.8 There Are Many Shells </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:31:05Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch01_01.htm"TITLE="1. Introduction"><LINKREL="prev"HREF="ch01_07.htm"TITLE="1.7 Power Grows on You "><LINKREL="next"HREF="ch01_09.htm"TITLE="1.9 Which Shell Am I Running? "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch01_07.htm"TITLE="1.7 Power Grows on You "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 1.7 Power Grows on You "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 1<BR>Introduction</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch01_09.htm"TITLE="1.9 Which Shell Am I Running? "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 1.9 Which Shell Am I Running? "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-1008">1.8 There Are Many Shells </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-1049"></A>With most operating systems, the command intepreter isbuilt in; it is an integral part of the operating system. With UNIX,your command interpreter is just another program. Traditionally,a command interpreter is called a &quot;shell,&quot; perhaps because itprotects you from the underlying kernel&nbsp;- or because it protectsthe kernel from you!</P><PCLASS="para">Several different shells are available: you are free to choose the onethat best suits your interests or your application. The most commonones are:</P><DLCLASS="variablelist"><DTCLASS="term"><EMCLASS="emphasis">sh</EM></DT><DDCLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-1059"></A>The Bourne shell (named after its creator, Steve Bourne).This is the oldest of the current UNIX shells and isavailable on most UNIX systems.(Some systems have replaced <EMCLASS="emphasis">sh</EM> with a newer shell, like <EMCLASS="emphasis">ksh</EM> or<EMCLASS="emphasis">bash</EM>, that has the features of <EMCLASS="emphasis">sh</EM> and more.)It is a bit primitive and lacksjob control features (the ability to move jobs from the foreground tothe background).Most UNIX users considerthe Bourne shell superior for shell programming or writingcommand files.</P></DD><DTCLASS="term"><EMCLASS="emphasis">csh</EM></DT><DDCLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-1070"></A>The C shell. It was developed at Berkeley as part of their UNIXimplementation and has been by far the most popular shell for interactive use.You will occasionally find a System V UNIX where the C shell isn'tavailable, but this is very rare. It has a lot of nice features thataren't available in the Bourne shell, including<SPANCLASS="link">job control (<ACLASS="linkend"HREF="ch12_08.htm"TITLE="Job Control in a Nutshell ">12.8</A>)</SPAN>and<SPANCLASS="link">history (<ACLASS="linkend"HREF="ch11_02.htm"TITLE="History in a Nutshell ">11.2</A>)</SPAN>(the ability to repeat commands that you have already given).However, while youwon't have trouble with normal usage,it isn't hard for a shell programmer to push the C shell to<SPANCLASS="link">its limits (<ACLASS="linkend"HREF="ch47_02.htm"TITLE="C Shell Programming Considered Harmful ">47.2</A>)</SPAN>.There are a lot of hidden bugs.</P></DD><DTCLASS="term"><EMCLASS="emphasis">ksh</EM></DT><DDCLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-1080"></A>The Korn shell (also named after its creator, David Korn).The Korn shell iscompatible with the Bourne shell, but has most of the C shell'sfeatures plus some completely new features, like<SPANCLASS="link">history editing (<ACLASS="linkend"HREF="ch11_13.htm"TITLE="Shell Command-Line Editing ">11.13</A>)</SPAN>:theability to recall old commands and edit them before executing them. Itis also more reliable than <EMCLASS="emphasis">csh</EM>.The Korn shell is a standard part of UNIXSystem&nbsp;V Release&nbsp;4; it has also been included in some other UNIX implementions.</P></DD><DTCLASS="term"><EMCLASS="emphasis">bash</EM></DT><DDCLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-1089"></A><ACLASS="indexterm"NAME="AUTOID-1091"></A><ACLASS="indexterm"NAME="AUTOID-1094"></A>The &quot;Bourne-again&quot; shell developed by the<SPANCLASS="link">Free Software Foundation (<ACLASS="linkend"HREF="glossary.htm#UPT-ART-1010"TITLE="Glossary">52.9</A>)</SPAN>.<SPANCLASS="link"><EMCLASS="emphasis">bash</EM> (<ACLASS="linkend"HREF="ch08_02.htm"TITLE="Introduction to bash">8.2</A>)</SPAN>is fairly similar to the Korn shell.It has many ofthe C shell's features, plus history editing and a built-in help command.</P></DD><DTCLASS="term"><EMCLASS="emphasis">tcsh</EM></DT><DDCLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-1104"></A>You may run into some extended versions of the C shell like <EMCLASS="emphasis">tcsh</EM>.<SPANCLASS="link"><EMCLASS="emphasis">tcsh</EM> (<ACLASS="linkend"HREF="ch08_03.htm"TITLE="Introduction to tcsh">8.3</A>)</SPAN>works like the original C shell&nbsp;- but with more features, and fewer mis-features.</P></DD></DL><PCLASS="para">There are also a fewthird-party shells that serve special purposes, like emulating the<ACLASS="indexterm"NAME="AUTOID-1110"></A><ACLASS="indexterm"NAME="AUTOID-1113"></A>VAX/VMS command language (DCL). I don't know if there is aDOS-lookalike shell available, but there probably is. Why you wouldwant it is another question: all of the standard UNIX shells do a lotmore than the DOS command interpreter. Furthermore, I like todiscourage UNIX users from pretending that UNIX is something else.You are going to be spending a lot of time using UNIX: you will bebetter off learning it properly than trying to make it look like someother operating system.</P><PCLASS="para">In this book, we'll stick to the C shell and <EMCLASS="emphasis">bash</EM> for interactive use.Because <EMCLASS="emphasis">bash</EM> and <EMCLASS="emphasis">ksh</EM> can read scripts written for theoriginal Bourne shell, we use <EMCLASS="emphasis">sh</EM> for shell programming.</P><PCLASS="para">Where we talk about &quot;the Bourne Shell&quot; or <EMCLASS="emphasis">sh</EM>, it's usually a safe betthat the information applies to <EMCLASS="emphasis">bash</EM> and <EMCLASS="emphasis">ksh</EM> too.In the same way, &quot;the C shell&quot; generally also means <EMCLASS="emphasis">tcsh</EM>-and, insome cases, <EMCLASS="emphasis">bash</EM> as well.Just because <EMCLASS="emphasis">bash</EM>, <EMCLASS="emphasis">ksh</EM> and <EMCLASS="emphasis">tcsh</EM> have the features ofthe shells they came from, though, it isn't safe to assume that theirfeatures are in the original <EMCLASS="emphasis">csh</EM> or <EMCLASS="emphasis">sh</EM> too.</P><PCLASS="para">If you're new to UNIX, don't worry about keeping track of all these shells.In this book, we talk mostly about the C and Bourne shells.Those two shell &quot;styles&quot; are all you really need to know at the start.Later, you can learn and appreciate what's been added to <EMCLASS="emphasis">ksh</EM>,<EMCLASS="emphasis">tcsh</EM>, and <EMCLASS="emphasis">bash</EM>.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">ML</SPAN>, <SPANCLASS="authorinitials">JP</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch01_07.htm"TITLE="1.7 Power Grows on You "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 1.7 Power Grows on You "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch01_09.htm"TITLE="1.9 Which Shell Am I Running? "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 1.9 Which Shell Am I Running? "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">1.7 Power Grows on You </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">1.9 Which Shell Am I Running? </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

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