Linux 执行Shell脚本文件

Linux中的脚本文件一般都是以.sh结尾的。sh 是Unix 标准默认的shell脚本语言。
创建一个hello.sh 文件,输入以下脚本。

#!/bin/bash

# remark
echo hello

使用 chmod +x hello.sh  添加脚本权限。

使用以下任一方式执行脚本,建议使用第一种。

  •  bash hello.sh 
  •  ./hello.sh 
  •  /data/hello.sh 
  •  . hello.sh 
原文地址:https://www.cnblogs.com/RainFate/p/14214217.html