Unix Shells: C, Bourne, Bourne Again, Korn, and Tenex Shells

download Unix Shells:  C, Bourne, Bourne Again, Korn, and Tenex Shells

of 21

  • date post

  • Category


  • view

  • download


Embed Size (px)


Unix Shells: C, Bourne, Bourne Again, Korn, and Tenex Shells. Presentation by: Katie Harris Andrew Murray. Introduction. Numerous types of shells offered Why so many shells? Some are original shells and others combine features of the original shells - PowerPoint PPT Presentation

Transcript of Unix Shells: C, Bourne, Bourne Again, Korn, and Tenex Shells

  • Unix Shells: C, Bourne, Bourne Again, Korn, and Tenex ShellsPresentation by:Katie HarrisAndrew Murray

  • Introduction Numerous types of shells offeredWhy so many shells?Some are original shells and others combine features of the original shells5 shells: Bourne Shell, Bourne Again Shell, C Shell, Korn Shell, and Tenex Shell

  • Bourne ShellDefault Unix Shell created in 1977 by Stephen BourneThe UNIX Programming EnvironmentFoundation for future shellsVery strong and powerful syntactical languageControlling input and output File Descriptor 2Larger argument list size and the idea of having environment variables

  • C ShellDeveloped by Bill Joy at the University of California at BerkeleyExtensive command language with syntax similar to the C programming languageJob control features of the BSD kernelNever very popularAliases Command HistoryBourne = Programming, C-Shell = Command Interpretation

  • Bash ShellBourne-again shell developed as a part of the GNU project by Brian Fox in 1987Default shell on most GNU/Linux and Mac OS X Panther systemsFreely distributed and combines C-Shell and Bourne Shell File completion Easier History Use

  • Korn ShellCreated by David Korn in AT&T Labs in 1983Compatible with Bourne ShellUtilizes both features from the Bourne Shell and the C ShellSome features include: coprocesses and one-dimensional arraysThe Korn shell is an interactive command interpreter and command programming language. The shell carries out commands specified at the terminal or from a file.

  • Tenex ShellCreated by Ken GreerTcsh is an enhanced, but completely compatible version of the Berkeley UNIX C shell (csh). It is a command language interpreter usable both as an interactive login shell and a shell script command processor. It includes a command-line editor, programmable word completion, spelling correction, a history mechanism, job control and a C-like syntax.

  • Shell Features sh csh ksh bash tcsh Job control N Y Y Y Y Aliases N Y Y Y Y Shell functions Y(1) N Y Y N "Sensible" Input/Output redirectionY N Y Y N Directory stack N Y Y Y Y Command history N Y Y Y Y Command line editing N N Y Y Y Vi Command line editing N N Y Y Y(3) Emacs Command line editing N N Y Y YRebindable Command line editing N N N Y Y User name look up N Y Y Y Y

  • Shell Features(2) sh csh ksh bash tcshLogin/Logout watching N N N N YFilename completion N Y(1) Y Y YUsername completion N Y(2) Y Y YHostname completion N Y(2) Y Y YHistory completion N N N Y YFully programmable Completion N N N N YMh Mailbox completion N N N N(4) N(6)Co Processes N N Y N N Builtin artithmetic evaluation N Y Y Y Y Can follow symbolic links invisibly N Y Y Y YPeriodic command execution N N N N YCustom Prompt (easily) N N Y Y Y Sun Keyboard Hack N N N N NSpelling Correction N N N N Y

  • Shell Features(3) sh csh ksh bash tcshProcess Substitution N N N Y(2) NUnderlying Syntax sh csh sh sh csh Freely Available N N N(5) Y Y Checks Mailbox N Y Y Y Y Tty Sanity Checking N N N N YCan cope with large argument lists Y N Y Y YHas non-interactive startup file N Y Y(7) Y(7) Y Has non-login startup file N Y Y(7) Y YCan avoid user startup files N Y N Y NCan specify startup file N N Y Y NLow level command redefinition N N N N NHas anonymous functions N N N N N List Variables N Y Y N Y Full signal trap handling Y N Y Y N

  • Shell Features(4) sh csh ksh bash tcshFile no clobber ability N Y Y Y Y Local variables N N Y Y N Lexically scoped variables N N N N NExceptions N N N N N

    Y Feature can be done using this shell.N Feature is not present in the shell.F Feature can only be done by using the shells function mechanism.L The readline library must be linked into the shell to enable this Feature. This feature was not in the orginal version, but has since become almost standard.This feature is fairly new and so is often not found on many versions of the shell, it is gradually making its way into standard distribution.The Vi emulation of this shell is thought by many to be incomplete.This feature is not standard but unoffical patches exist to perform this.A version called 'pdksh' is freely available, but does not have the full functionality of the AT&T version.This can be done via the shells programmable completion mechanism.Only by specifing a file via the ENV environment variable.

  • Redirection and Pipes

  • Common Features to Bourne, Korn, and C ShellsSymbol/CommandMeaning/Action>Redirect output>>Append to file|>!Force redirection>file 2>&1>file 2>&1>& fileCombine stdout and stderr{ }Expand elements in list` `` `` `Substitute output of enclosed command$( )Substitute output of enclosed command$HOME$HOME$homeHome directory~~Home directory symbolvar=valuevar=valueset var=valueVariable assignmentexport varexport var=valsetenv var valSet environment variable${nn}More than nine args can be referenced$@$@All args as separate words$#$#$#argvNumber of arguments
  • Differing Features of Bourne, Korn, and C Shells(2)shkshcshMeaning/Action$?$?$statusExit status$!$!Background exit status$-$-Current options. file. filesource fileRead commands in filealias x=yalias x yName x stands for ycasecaseswitch/caseChoose alternativescd ~-popd/pushdSwitch directoriesdonedoneendEnd a loop statementesacesacendswEnd case or switchexit [n]exit [n]exit [(expr)]Exit with a statusfor/dofor/doforeachLoop through variablesprint rglobIgnore echo escapeshashalias thashstatDisplay hashed commentshash cmdsalias t cmdsrehashRemember command locationshash rPATH=$PATHunhashForget command locationshistoryhistoryList previous commands

  • Differing Features of Bourne, Korn, and C Shells(3)shkshcshMeaning/Actionr!!Redo previous commandr str!strRedo command that starts with str\r x=cmd!cmd:s/x/yEdit command, then executeif [ $i eq 5]if ((i==5))if ($i==5)Sample if statementfifiendifEnd if statementulimitulimitlimitSet resource limitspwdpwddirsPrint working directoryreadread$