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


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

相关文章
|
8天前
|
存储 安全 Unix
七、Linux Shell 与脚本基础
别再一遍遍地敲重复的命令了,把它们写进Shell脚本,就能一键搞定。脚本本质上就是个存着一堆命令的文本文件,但要让它“活”起来,有几个关键点:文件开头最好用#!/usr/bin/env bash来指定解释器,并用chmod +x给它执行权限。执行时也有讲究:./script.sh是在一个新“房间”(子Shell)里跑,不影响你;而source script.sh是在当前“房间”里跑,适合用来加载环境变量和配置文件。
149 10
|
8天前
|
存储 Shell Linux
八、Linux Shell 脚本:变量与字符串
Shell脚本里的变量就像一个个贴着标签的“箱子”。装东西(赋值)时,=两边千万不能有空格。用单引号''装进去的东西会原封不动,用双引号""则会让里面的$变量先“变身”再装箱。默认箱子只能在当前“房间”(Shell进程)用,想让隔壁房间(子进程)也能看到,就得给箱子盖个export的“出口”戳。此外,Shell还自带了$?(上条命令的成绩单)和$1(别人递进来的第一个包裹)等许多特殊箱子,非常有用。
62 2
|
1月前
|
算法 Linux Shell
Linux实用技能:打包压缩、热键、Shell与权限管理
本文详解Linux打包压缩技巧、常用命令与原理,涵盖.zip与.tgz格式操作、跨系统传文件方法、Shell运行机制及权限管理,助你高效使用Linux系统。
Linux实用技能:打包压缩、热键、Shell与权限管理
|
3月前
|
Web App开发 缓存 安全
Linux一键清理系统垃圾:释放30GB空间的Shell脚本实战​
这篇博客介绍了一个实用的Linux系统盘清理脚本,主要功能包括: 安全权限检查和旧内核清理,保留当前使用内核 7天以上日志文件清理和系统日志压缩 浏览器缓存(Chrome/Firefox)、APT缓存、临时文件清理 智能清理Snap旧版本和Docker无用数据 提供磁盘空间使用前后对比和大文件查找功能 脚本采用交互式设计确保安全性,适合定期维护开发环境、服务器和个人电脑。文章详细解析了脚本的关键功能代码,并给出了使用建议。完整脚本已开源,用户可根据需求自定义调整清理策略。
213 1
|
5月前
|
Linux Shell
Centos或Linux编写一键式Shell脚本删除用户、组指导手册
Centos或Linux编写一键式Shell脚本删除用户、组指导手册
128 4
|
5月前
|
Linux Shell 数据安全/隐私保护
Centos或Linux编写一键式Shell脚本创建用户、组、目录分配权限指导手册
Centos或Linux编写一键式Shell脚本创建用户、组、目录分配权限指导手册
271 3
|
6月前
|
Linux Shell
在Linux、CentOS7中设置shell脚本开机自启动服务
以上就是在CentOS 7中设置shell脚本开机自启动服务的全部步骤。希望这个指南能帮助你更好地管理你的Linux系统。
435 25
|
6月前
|
Linux Shell
shell_42:Linux参数移动
总的来说,参数移动是Linux shell脚本中的一个重要概念,掌握它可以帮助我们更好地处理和管理脚本中的参数。希望这个解释能帮助你理解和使用参数移动。
94 18
|
Shell Linux
Linux shell编程学习笔记30:打造彩色的选项菜单
Linux shell编程学习笔记30:打造彩色的选项菜单
|
8月前
|
Shell Linux
【linux】Shell脚本中basename和dirname的详细用法教程
本文详细介绍了Linux Shell脚本中 `basename`和 `dirname`命令的用法,包括去除路径信息、去除后缀、批量处理文件名和路径等。同时,通过文件备份和日志文件分离的实践应用,展示了这两个命令在实际脚本中的应用场景。希望本文能帮助您更好地理解和应用 `basename`和 `dirname`命令,提高Shell脚本编写的效率和灵活性。
601 32