shell脚本编程需要注意以下几个事项:
以下为第一个shell编程脚本,脚本名称为first_shell.sh,过程如下:
touch first_shell.sh #创建文件
vi first_shell.sh #编辑文件
#! /bin/bash
#By Author song
echo “hello world !”
其中第一行为固定格式,定义该脚本所使用的shell类型;第二行表示脚本创建人,#号表示注解;第三行echo“Hello World!”shell脚本主命令,执行该脚本呈现的内容。
chmod o+x first_shell.sh
./first_shell.sh
也可以使用命令执行脚本
/bin/sh first_shell.sh