shell 脚本运行配置
1. 查看环境
-
echo $PATH
QQ截图20230223120040.png
2. 编写脚本
- touch test.sh 创建 test.sh 文件
- vim test.sh 编辑test.sh 文件
#!/bin/bash
# testing the if statement
if pwd
then
echo "It worked"
fi
3. 执行脚本
[root@VM-0-7-centos test]# ./test.sh
-bash: ./test.sh: Permission denied
4.授权
chmod u+x test.sh
5. 再次执行
[root@VM-0-7-centos test]# ./test.sh
/usr/local/test
It worked
[root@VM-0-7-centos test]#
网友评论