标签:
创建一个shell脚本
mkdir shell
vim first.sh
#!/bin/bash ##The first test shell script. ##Written by wangshaojun. ls /tmp/ echo "my home is $HOME" echo "This is first script"
执行shell脚本,两种方法
bash first.sh
mysql.sock www_slow.log
2015-12-31.wangshaojun.root.history-timestamp pear www.sock
2016-01-01.wangshaojun.root.history-timestamp www1.sock
my home is /root
This is first script.
或者
sh first.sh
第二种方法
chmod a+x first.sh
./first.sh
绝对路径
/root/shell/first.sh
脚本的执行过程
sh -x first.sh
+ ls /tmp
12334 mysql.sock www_slow.log
2015-12-31.wangshaojun.root.history-timestamp pear www.sock
2016-01-01.wangshaojun.root.history-timestamp www1.sock
+ echo ‘my home is /root‘
my home is /root
+ echo ‘This is first script.‘
This is first script.
可以排查错误
标签:
原文地址:http://www.cnblogs.com/wangshaojun/p/5093200.html