02.shell脚本的执行方式

目录

1.按照可执行文件来执行:

2.通过bash 【脚本】或 . 【脚本】的方式执行脚本

3.EOF的脚本使用方式

脚本要赋予执行权限才能正常执行,执行方式为:

1.按照可执行文件来执行:

[root@localhost ~]# chmod 755 hello.sh

[root@localhost ~]# /root/hello.sh

  或者                    

[root@localhost ~]# ./hello.sh

2.通过bash 【脚本】或 . 【脚本】的方式执行脚本

当没有执行权限的时候,可以通过bash 【脚本】或 . 【脚本】的方式来执行脚本。

[root@localhost ~]# .  hello.sh

或者

[root@localhost ~]# bash ./hello.sh

3.EOF的脚本使用方式

[root@localhost ~]# vim p.sh #写入以下内容

#!/bin/bash

cat <<EOF

========================

1.mysql

2.httpd

3.oracle

=======================

EOF

[root@localhost ~]# chmod +x

[root@localhost ~]# ./p.sh #查看效果

猜你喜欢

转载自blog.csdn.net/weixin_46659843/article/details/123475282