第一章节 理解Shell基础

admin
2024-01-25 / 0 评论 / 66 阅读 / 正在检测是否收录...

shell-logo-black-and-white-4.png## 第一章节 理解Shell基础

  1.1 介绍Shell是什么以及为什么使用Shell

Shell 为你提供了一个连接 Unix 系统的界面。它收集输入,并根据输入执行程序。程序执行完毕后,它会显示该程序的输出结果。

shell 是我们运行命令、程序和 shell 脚本的环境。Shell 有不同的类型,就像操作系统有不同的类型一样。每种 shell 都有自己的一套公认的命令和功能。

shell 提示符

提示符 $ 称为命令提示符,由 shell 发出。当提示符显示时,您可以键入命令。

按 Enter 键后,Shell 会读取你的输入。它通过查看输入的第一个单词来确定您要执行的命令。单词是一组不间断的字符。空格和制表符分隔单词。

下面是一个日期命令的简单示例,该命令显示当前日期和时间

[root@y36-server ~]# date
2023年 09月 19日 星期二 22:08:05 CST

  1.2 Shell的种类:Bash、sh、zsh等

在 Unix 中,主要有两种 shell

  • Bourne shell − If you are using a Bourne-type shell, the $ character is the default prompt.
  • C shell − If you are using a C-type shell, the % character is the default prompt.

Bourne Shell 有以下子类别

  • Bourne shell (sh)
  • Korn shell (ksh)
  • Bourne Again shell (bash)
  • POSIX shell (sh)

不同的 C 型外壳如下

  • C shell (csh)
  • TENEX/TOPS C shell (tcsh)

最初的 Unix shell 是由 Stephen R. Bourne 于 20 世纪 70 年代中期在新泽西州 AT&T 贝尔实验室工作时编写的。

伯恩 shell 是 Unix 系统上出现的第一个 shell,因此被称为 "shell"。

在大多数 Unix 版本中,Bourne shell 通常安装为 /bin/sh。因此,它是编写可用于不同版本 Unix 的脚本的首选 shell。

1.3 执行Shell脚本的方法

./
sh 
bash 
0

评论 (0)

取消