目录
- 1、命令解释器
- 2、编程语言分类
- 3、Shell脚本执行方式
- 4、应用场景
- 总结
Shell命令解释器:介于 系统内核——>命令解释器——>外围应用程序:应用/命令/服务
Shell编程:bash编程
1、命令解释器
2、编程语言分类
解释型
[root@localhost ~]# vim 1.py
[root@localhost ~]# cat 1.py
print(\”hrllo world!\”)
[root@localhost ~]# python 1.py
hrllo world!
3、Shell脚本执行方式
1通过sh或bash执行
[root@localhost shell]# vim 01.exec.way.sh
[root@localhost shell]# cat 01.exec.way.sh
hostname
pwd
whoami
[root@localhost shell]# sh 01.exec.way.sh
localhost.localdomain
/root/shell
root
[root@localhost shell]# bash 01.exec.way.sh
localhost.localdomain
/root/shell
root
[root@localhost shell]# ll `which sh bash`
-rwxr-xr-x. 1 root root 964544 Apr 10 2018 /usr/bin/bash
lrwxrwxrwx. 1 root root 4 Mar 23 05:59 /usr/bin/sh -> bash
2通过source或 . 执行
[root@localhost shell]# . 01.exec.way.sh
localhost.localdomain
/root/shell
root
[root@localhost shell]# source 01.exec.way.sh
localhost.localdomain
/root/shell
root
3通过绝对路径或相对路径执行
[root@localhost shell]# ./01.exec.way.sh
-bash: ./01.exec.way.sh: Permission denied
[root@localhost shell]# chmod +x ./01.exec.way.sh
[root@localhost shell]# ls -l
total 4
-rwxr-xr-x. 1 root root 21 May 6 01:15 01.exec.way.sh
[root@localhost shell]# ./01.exec.way.sh
localhost.localdomain
/root/shell
root
4通过重定向符号运行
[root@localhost shell]# sh < 01.exec.way.sh
localhost.localdomain
/root/shell
root
[root@localhost shell]# bash < 01.exec.way.sh
localhost.localdomain
/root/shell
root
4、应用场景
应用及场景
总结
您可能感兴趣的文章:
- Shell脚本bash: ./t.sh:/bin/bash^M:损坏的解释器: 没有那个文件或目录