随笔:What is Bash? What is shell?

简介: 随笔:What is Bash? What is shell?
作为一名Linux初学者,在学习中会不断遇到各种各样的问题和疑问。我们都清楚,Linux(Unix)系统需要输入有很多命令,提到命令行,不得不提到两个相关的概念bash,shell。我个人觉得有必要了解和弄清楚,那么我跟大家分享一下我看到的【Bash Referenc Manual】文档中的相关知识。

首先是:

What is Bash?

Bash is the shell, or command language interpreter, for the GNU operatiing system. The name is an acronym for the 'Bourne-Again SHell', a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell (sh),which appeared in the Seven Edition Bell Labs Research version of Unix.

Bash is largely compatible with sh and incorporates useful features from the Korn shell (ksh) and the the C shell (csh). It is intended to be a conformant inplementation of the IEEE POSIX Shell and Tools portion of the IEEE POSIX specification (IEEE Standard 1003.1).It offers function improvements over (sh) for both interactive and programming use.

While the GNU operating system provides other shells, including a version of csh, Bash is the default shell. Like other GNU software, Bash is quite portable. It currently runs on nearly every version of Unix and a few other operating systems- independently-supported ports exist for MS-DOS,OS/2, and Windows platforms.

本人翻译水平有限,恳请批评指正!

我的译文如下:

Bash是什么?

Bash是GNU操作系统的shell(稍后解释什么是shell),或命令语言的解释器。这个名字是“Bourne-Again SHell"的首字母缩写,是Stephen Bourne的双关语,他是当前Unix shell的直系祖先的作者,这个概念出现在贝尔实验室的第七版Unix研究版本中。

Bash在很大程度上与sh兼容并结合了korn shell(ksh)和C shell(csh)的有用特性。旨在IEEE POSIX Shell 和IEEE POSIX规范的工具部分符合实施。它为交互和编程使用提供了比sh更好的功能。

虽然GNU操作系统提供了其他Shell,包括csh的一个版本,Bash是默认的shell。就像其他GNU软件一样,Bash具有相当的可移植性。它目前运行在几乎所有版本的Unix和一些其他 操作系统上。MS-DOS,OS/2和Windows 平台都有独立的支持端口。

What is a shell?

At its base, a shell is simply a macro processor that executes commands. The term macro processor means functionality where text and symbols are expanded to create larger expressions.

A Unix shell is both a command interpreter and a programming language. As a command interpreter, the shell provides the user interface to the rich set of GNU utilities. The programming language features allow these utilities to be combined. Files containing commands can be created, and become commands themselves. These new commands have the same status as system commands in directories such as /bin, allowing users or groups to establish custom environments to automate their common tasks.

Shells may be used interactively or non-interactively. In interactive mode, they accept input typed from the keyboard. When executing non-interactively, shells execute commands read from a file.

A shell allows execution of GNU commands, both synchronously and asynchronously. The shell waits for synchronous commands to complete before accepting more input; asynchronous commands continue to execute in parallel with the shell while it reads and executes additional commands. The redirection constructs permit fine-grained control of the input and output of those commands. Moreover, the shell allows control over the contents of commands’ environments.

Shells also provide a small set of built-in commands (builtins) implementing functionality impossible or inconvenient to obtain via separate utilities. For example, cd, break, continue, and exec cannot be implemented outside of the shell because they directly manipulate the shell itself. The history, getopts, kill, or pwd builtins, among others, could be implemented in separate utilities, but they are more convenient to use as builtin commands.

While executing commands is essential, most of the power (and complexity) of shells is due to their embedded programming languages. Like any high-level language, the shell provides variables, flow control constructs, quoting, and functions.

Shells offer features geared specifically for interactive use rather than to augment the programming language. These interactive features include job control, command line editing, command history and aliases.

译文:

什么是壳?

在它的基础上,shell只是一个执行命令的宏处理器。术语宏处理器意思是文本和符号被展开创建更大的表达式的功能。

Unix shell既是命令解释器也是编程语言。作为命令解释器,shell为丰富的GNU工具集提供用户接口。编程语言的特点允许这些工具被组合。文件包含命令可以被创建并成为命令本身。这些新命令和在目录中的系统命令(如/bin)有相同的地位。允许用户或者组建立自定义环境自动化它们的常见任务。

Shell可以以交互方式或非交互方式使用。在交互模式下,它们接受敲键盘的输入。在非交互式执行时,shell执行从文件读取的命令。

Shell 允许同步和异步方式执行GNU命令。shell在接受更多输入之前等待同步命令完成。在shell读取和执行其他命令时,异步命令继续与shell并行执行。重定向构造这些输入和输出命令的细粒度控制的许可。此外,shell允许控制命令环境的内容。

Shell还提供了一小套内置命令(内置函数),实现了通过单独的实用程序不可能或不方便获得的功能。例如:cd,break,continue和exec不能在shell之外执行,因为它们直接操纵shell本身。history,getopts ,kill 或者pwd等内置命令可以在单独的实用程序中执行。但是作为内置命令使用它们更加方便。

虽然执行命令是必不可少的,但是shell的强大(和复杂性)大多数归于它们的嵌入式编成语言。与任何高级语言一样,shell提供变量,流控制构造、引用和函数。

Shell提供了专门用于交互使用的特性而不是扩大编程语言。这些交互式特性包含作业控制,命令行编辑,命令历史记录和别名。

注:我的理解, bash是shell的增强版本,都是命令(CLI)解释器。shell提供了用户与内核进行交互操作的一种接口,它接收用户输入的命令并把命令送到内核去执行。shell是一种高级程序设计语言。

相关文章
|
7月前
|
Linux Shell Windows
4:Bash shell命令-步入Linux的现代方法
4:Bash shell命令-步入Linux的现代方法
102 0
|
Ubuntu 安全 Linux
不用安装虚拟机,直接在Windows上面运行Linux Bash Shell,嗯!真香!!!
不用安装虚拟机,直接在Windows上面运行Linux Bash Shell,嗯!真香!!!
308 0
|
4月前
|
缓存 Shell Linux
在Linux中,bash shell 中的 hash 命令有什么作用?
在Linux中,bash shell 中的 hash 命令有什么作用?
|
4月前
|
Shell Linux
在Linux中,使用bash shell实现条件判断和循环结构的例子是什么样的?
在Linux中,使用bash shell实现条件判断和循环结构的例子是什么样的?
|
7月前
|
存储 Shell Linux
【攻防世界】unseping (反序列化与Linux bash shell)
【攻防世界】unseping (反序列化与Linux bash shell)
|
7月前
|
Shell
shell 命令(一)概述【别名、 bash重定向 、定义变量】
shell 命令(一)概述【别名、 bash重定向 、定义变量】
64 0
|
7月前
|
Shell
Shell(如Bash)命令行技巧
Shell(如Bash)命令行技巧
54 2
|
7月前
|
Shell
在Shell(如Bash)中,`while`循环
在Shell(如Bash)中,`while`循环
106 2
|
7月前
|
机器学习/深度学习 Unix Shell
Shell编程基础入门(Bash|变量与输入输出重定向2&1)
Shell编程基础入门(Bash|变量与输入输出重定向2&1)
128 0
|
缓存 Shell 开发工具
【Shell编程】Shell中Bash基本功能
【Shell编程】Shell中Bash基本功能
103 0
【Shell编程】Shell中Bash基本功能