4,2.1Shel概述 ·1.She特点和主要版本 在 Linux系统中通常提供多种不同的 Shell,常用的有 Bourne shell(简称sh) C- shell(简称csh)、 Kon shell(简称ksh) 和 Bourne Again shell(简称bash)。bash 是 Linux中一个默认的shel,本节主要介 绍bash
– 4.2.1 Shell概述 • 1.Shell的特点和主要版本 • 在Linux系统中通常提供多种不同的 Shell,常用的有Bourne shell(简称sh)、 C-shell(简称csh)、Korn shell(简称ksh) 和Bourne Again shell(简称bash)。bash 是Linux中一个默认的shell,本节主要介 绍bash
2.Shel程序示例 Shel程序也可存放在文件上,下面是两 个shel程序示例。 【例41】由3条简单命令组成的shel 序(文件名为ex1)。 date pwd cd
• 2.Shell程序示例 • Shell程序也可存放在文件上,下面是两 个shell程序示例。 • 【例4.1】 由3条简单命令组成的shell程 序(文件名为ex1)。 • date • pwd • cd
【例42】带有控制结构的she程序(文 件名为ex2) #If no arguments,then listing the current directory #Otherwise, listing each subdirectory · If test$#=0 then Is else for i go Is-I Sil grep Ad done fi
•【例4.2】 带有控制结构的shell程序(文 件名为ex2)。 • #If no arguments , then listing the current directory. • #Otherwise,listing each subdirectory. • If test $# =0 • then ls • else • for i • do • ls –l $ i | grep ‘^d ‘ • done • fi
3. Shelli过程的建立和执行 称作She件或者She本( Shell script) 建立She程的步骤同建立普通文本文件 相同,利用编辑器(如v或 gedit)进行程序录 入和编辑加工
• 3.Shell过程的建立和执行 • 称作Shell文件或者Shell脚本(Shell script)。 • 建立Shell过程的步骤同建立普通文本文件 相同,利用编辑器(如vi或gedit)进行程序录 入和编辑加工