Linux Shell的类别

The Bourne Shell

When Unix was first born, it had a very basic shell written by Ken Thompson, one of the creators
of Unix. The Bourne shell was written by Steve Bourne in 1979 as a scriptable Unix shell. All other
shells have a prefix to qualify which shell they are — ksh, csh, zsh, and so on — but the Bourne shell
does not call itself bsh because it simply is “the shell,” so its canonical path is /bin/sh. Other shells
came along later with more features, while staying generally compatible with the Bourne shell —
some more compatible than others.
One of the most significant new concepts that the Bourne shell provided was the pipeline, the structure
that allows one process to pass its output to the input of another process. This was a dramatic
change in the capability of a shell command. Bourne also introduced variables and flow control,
turning the shell from being a very basic command interpreter into a flexible scripting language.

The KornShell

The Kornshell (ksh) was written by David Korn in 1983. It is a very popular shell for scripting as well
as interactive use, particularly on proprietary Unices. Like bash and dash, it is backward-compatible
with the Bourne shell but adds new features and syntax. Ksh introduced cursor-key navigation of the
shell history, as well as providing arrays and floating-point math. For a long time, ksh was proprietary
Unix software of AT&T, so pdksh (now mksh, http://mirbsd.de/mksh) is a Free Software equivalent
to ksh93. After ksh93 was released under IBM’s Common Public License in 2005, most GNU/
Linux distributions included ksh93 instead of pdksh or mksh, as did OpenSolaris. As a result, whenever
you find ksh on a recent system, it is likely to be the genuine ksh93 and not a clone.

The common ground between ksh and Bourne functionality was used to define the POSIX standard
for /bin/sh, so ksh is a significant shell scripting language. In traditional Unix systems, it is quite
acceptable for the root user’s shell to be set to /bin/ksh. It is the default shell on IBM’s AIX Unix.
/etc/init.d scripts will still be run under the Bourne shell, but the interactive root shell can be ksh
(often with the -o vi option to provide vi-like history recall).
Microsoft’s Services For Unix (SFU — now discontinued) provided an almost-compatible ksh shell for
the Windows environment, although it was based on mksh, which at the time was not quite compatible
with the original ksh. At http://lists.blu.org/pipermail/discuss/1998-August/002393.html,
you can read the story of how David Korn queried a Microsoft product manager about his choice of
Kornshell implementation during a presentation about SFU. Korn criticized the choice of implementation
because it was incompatible with genuine ksh, and asked whether Microsoft had considered any of
the more compatible ksh variants. Only after the poor Microsoft representative had tried to claim that
their implementation of the Kornshell was fully compatible with the Kornshell was it eventually pointed
out to him that the person asking the awkward questions about Kornshell compatibility was David
Korn himself.

The C Shell

The C shell (csh) was written in the 1970s by Bill Joy, one of the founders of Sun Microsystems and
also a very prolific BSD Unix hacker. One of the main attractions of csh was that its syntax looked
a lot more like the C language, which many systems programmers are very familiar with. It was also

a better interactive shell than the Bourne shell, providing the history command for the first time.
It also added job control and the concept of using the tilde (~) to represent the current user’s home
directory. All of these features (but not the C-style syntax) have been taken on by all of the other
shells listed here.
In 1996, Tom Christiansen wrote a widely distributed article entitled “Csh Programming
Considered Harmful” (http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/), which
pointed out some of the ways in which csh syntax can be counterintuitive or limiting to the systems
programmer. The issues that Christiansen raises are particularly focused around the areas of redirection
and process control.

The Tenex C Shell

 

Tcsh is the Tenex Csh, and offers many improvements to the standard csh, while remaining totally
compatible with csh. Its improvements over csh include better history control; pushd and popd for
stacking directory positions; terminal locking; and which, where, and also read-only variables. It
also provides spelling correction; an interactive tcsh will prompt the user with suggested options if it
suspects that a typing error has been made.
In addition to automatic completion of commands and filenames, tcsh also adds automatic completion
of variable names. It can be configured to do this in either case-sensitive or case-insensitive mode.

The Z Shell

 

The Z shell (zsh) was written by Paul Falstad in 1990. It was intended to be a ksh-like shell but also
included some csh-like features because csh was a very popular interactive shell in the 1970s and
1980s. It is particularly good as an interactive shell. It does not claim full POSIX or Bourne compatibility,
which allows it greater flexibility to add new features, although it does aim to be ksh compatible.
It can change its behavior with the emulate command, or if called as /bin/sh or /bin/ksh, to
act more like those shells.
Zsh is a lot like bash for interactive use, with similar, although in some ways more featureful, history
recall and command completion. The compctl command can be used to customize just how the
completion works. Globbing syntax is slightly different from ksh and Bourne shell, and arrays are
indexed from 1, not 0.

The Bourne Again Shell

 

Bash is the standard interactive shell on most GNU/Linux and Mac OSX systems, and is becoming
popular with traditional Unix users, too. It is also the default shell for the Cygwin environment,
which provides GNU tools under Microsoft Windows. It is compatible with the Bourne shell, but
adds a number of extra features, most of which are covered in this book. The name of the bash shell
(the “Bourne Again shell”) is a play on the name of the author of the Bourne shell.

Bash was initially written by Brian Fox in 1988 for the Free Software Foundation (FSF) and is currently
maintained by Chet Ramey. It takes some ideas from various shells including csh and ksh.
Most noticeably, bash uses [[ … ]], $( … ), and (( … )) syntaxes from ksh.
Bash, if called as sh, acts more like the Bourne shell in the confi guration fi les it reads. This is documented
in more detail later in this chapter.

the deBian alMQuiSt Shell

 

Dash started life in 1989 as the Almquist Shell (ash), written by Kenneth Almquist. It was ported for
the Debian project in 1999 by Herbert Xu as the Debian Almquist Shell (dash). Like bash, it aims for
POSIX compliance, but unlike bash, it tries nothing more; it aims only to be a POSIX-compliant shell.
This makes it smaller, lighter, and faster than bash. It therefore replaces bash as the default /bin/sh in
many GNU/Linux distributions, which generally retain bash for interactive use, using dash for system
scripts, particularly startup scripts.
The longstanding availability of bash as /bin/sh on GNU/Linux caused some problems when
migrating to dash, as a lot of system scripts called /bin/sh as their interpreter but expected
to be able to use features of bash. The site https://bugs.launchpad.net/ubuntu/+source/
dash/+bug/61463 provides a list of many of the problems experienced when Ubuntu 6.10 moved
from bash to dash as the default /bin/sh in 2006.

 

Shell Scripting Expert RECIP ES for Linux, Bash, and More

Seve Parker ISBN: 978-0-470-02448-5

Linux Shell Scrpting with Bash

Linux Shell Scripting Cookbook 4397758.8717885311

时间: 2024-08-04 10:07:14

Linux Shell的类别的相关文章

思维导图学 Linux Shell攻略之干货篇 mysql数据库脚本管理系统

原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://dba10g.blog.51cto.com/764602/1610653 以结果为导向的学习,才是最有效率学习.笔者以前也曾经隔三差五的学习linux shell编程来着.给我的感觉就是,今天学了,后天忘了,一星期之后就白学了. 还好,最近自己平时没啥事,一直照着<linux shell攻略>,学做一些小例子,看着自己写的shell程序,简单的几行程序,实现一些好玩的效果,信心

linux shell rman备份文件的脚本

rman备份脚本 #! /bin/bash su - oracle <<! rman target /<<EOF backup AS COMPRESSED BACKUPSET database include current controlfile format'/orabak/db_%d_%T_%s' plus archivelog format'/orabak/arch_%d_%T_%s' delete allinput; delete noprompt obsolete; e

linux shell编程中date命令的用法

在linux shell编程中,经常用到日期的加减运算 以前都是自己通过expr函数计算,很麻烦 其实date命令本身提供了日期的加减运算 非常方便.例如:得到昨天的时间 date +%Y%m%d --date="-1 day" date 用法: date [OPTION]... [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] date 可以用来显示或设定系统的日期与时间. 令1.在显示方面,使用者可以设定欲显

Linux Shell 编程实战技巧

避免定时任务脚本的常见问题 很多脚本在实际使用的时候往往是以定时任务的方式运行,而非手工运行.但是实现同样功能的脚本在这两种运行方式下可能遇到的问题不尽相同. 以定时任务方式运行的脚本往往会遇到以下几个问题. 路径问题:当前目录往往不是脚本文件所在目录.因此,脚本在引用其使用的外部文件,如配置文件和其它脚本文件时,无法方便得使用相对路径. 命令找不到问题:脚本中使用到的一些外部命令,在手工执行脚本的时候可以正常调用.但是在定时任务下运行则可能出现脚本解析器找不到相关命令的问题. 脚本重复运行问题

在Linux Shell下将汉字转换为Url编码

在linux 的shell环境下有一个od命令可以将文件按不同的进制的ascii码输 出,该功能可以完成在linux shell下将汉字转换为url编码的任务. url编码是十六进制的形如%E6%9C%8D%E5%8A%A1%E5的字符串,test是包含 "数据库网络,"这几个字符的文件,以下命令输出: #od -t x /test 0000000 ddbefdca f8cde2bf 0a2ce7c2 0000014 该字符串对应的url编码为 %CA%FD%BE%DD%BF%E2%C

Linux shell编程基础 三、shell的基本结构

shell结构大体是由设定变量.内置命令.shell的语法结构.函数组成. 使用实例说明:test.sh #!/bin/bash #说明使用/bin/bash作为这个脚本的解释器 #定义一个函数 function my_fun () { echo "Hello, $1,today is $2" } #定义连个变量 name=$1 today=`date` #函数调用 my_fun "$name" "$today" 上面的这个脚本要想运行还需要做一

一些Linux Shell中的权限相关知识总结

  这篇文章主要介绍了一些Linux Shell中的权限相关知识总结,使Linux入门学习中的基础知识,需要的朋友可以参考下 一个文件一经创建,就具有三种访问方式: 1) 读,可以显示该文件的内容. 2) 写,可以编辑或删除它. 3) 执行,如果该文件是一个s h e l l脚本或程序. 按照所针对的用户,文件的权限可分为三类: 1) 文件属主,创建该文件的用户. 2) 同组用户,拥有该文件的用户组中的任何用户. 3) 其他用户,即不属于拥有该文件的用户组的某一用户 文件的全部信息包括以下: 文

Linux Shell 通配符、元字符、转义符使用实例介绍

  下面是一个实例: 代码如下: [chengmo@localhost ~/shell]$ ls a.txt b.txt c.old #2 [chengmo@localhost ~/shell]$ ls *.txt a.txt b.txt #3 [chengmo@localhost ~/shell]$ ls d*.txt ls: 无法访问 d*.txt: 没有那个文件或目录 从上面这个实例,不知道大家有没有发现问题呢.我们先了解一下,通配符相关知识,再分析下这个实例吧. 一.linux shel

Linux shell脚本基础学习详细介绍(完整版)

Linux shell脚本基础学习这里我们先来第一讲,介绍shell的语法基础,开头.注释.变量和 环境变量,向大家做一个基础的介绍,虽然不涉及具体东西,但是打好基础是以后学习轻松地前提. 1. Linux 脚本编写基础 ◆1.1 语法基本介绍1.1.1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序.在这个例子中我们使用/bin/sh来执行程序. 当编辑好脚本时,如果要执行该脚本,还必须使其可执行. 要使脚本可