1.脚本的创建
vim script.sh | 用 vim 编写脚本 |
---|---|
#!/bin/bash | 脚本使用的解释器,通常用幻数 “#!” 指定 |
#AUTHOR | 脚本作者 |
#DATE | 脚本创作时间 |
脚本作者联系方式 | |
#VERSION | 脚本的版本 |
脚本示例:
vim hello.sh
#!/bin/bash
#AUTHOR:timinglee
#VERSION:1.0
#MAIL:timinglee@westos.org
#DATE:xxxx-xx-xx
echo "hello world!"
2.脚本的调试
sh -x scritps.sh //适用于所有 shell 脚本
3.脚本的执行:真机测试
vim tset.sh
#!/bin/tcsh
watch -n 1 `date`
chmod +x test.sh
sh test.sh | 当前环境下重新开了一个默认环境执行脚本 |
---|---|
/mnt/test.sh 与 ./test.sh | 当前环境下开启文件中指定的环境 |
source test.sh 与 . test.sh | 当前环境 |