Shell 脚本(shell script),是一种为 shell 编写的脚本程序。

Linux 的 Shell 种类众多,常见的有:

声明脚本解释器

#! 告诉系统其后路径所指定的程序即是解释此脚本文件的 Shell 程序。

#!/bin/bash #!/bin/sh

脚本的执行

chmod +x ./test.sh 给予可执行权限

./test.sh 执行脚本

变量

变量名和等号之间不能有空格。

变量引用使用$

Example:

 #!/bin/bash
 clear
 echo "this is my first shell script."
 authorName = "keyon"
 echo $authorName