一、什么是shell
1、Shell是用户与内核进行交互操作的一种接口,目前最流行的Shell称为bash Shell
2、Shell也是一门编程语言<解释型的编程语言>,即shell脚本
3、一个系统可以存在多个shell,可以通过cat /etc/shells命令查看系统中安装的shell,不同的shell可能支持的命令语法是不相同的
二、shell脚本的执行方式
第一种方式:
1、如shell脚本文件的位置是/root/helloword.sh
2、赋予可执行权限:chmod +x /root/helloword.sh
3、执行shell脚本:./root/helloword.sh
第二种方式:使用解析器解析执行
1、如shell脚本文件的位置是/root/helloword.sh
2、sh /root/helloword.sh
第三种方式:在脚本的路径前加两个点“. .”;
1、如shell脚本文件的位置是/root/helloword.sh
2、执行脚本:. ./root/helloword.sh
三、shell脚本的helloword.sh
1、新建脚本:
[root@localhost shell]# vi helloword.sh2、编辑helloword.sh文件
#/bin/bash
echo "hello word"
~
~
3、执行helloword.sh
[root@localhost shell]# chmod +x helloword.sh
[root@localhost shell]# ./helloword.sh
hello word
[root@localhost shell]#
本文介绍了Shell作为用户与内核交互的接口及其编程语言特性,并详细展示了三种执行Shell脚本的方法及如何创建并运行一个简单的helloworld脚本。

1064

被折叠的 条评论
为什么被折叠?



