wiki:linux:sh-run
shell脚本与运行
.sh 脚本
一个典型的sh脚本示例:
- hello.sh
#!/bin/bash ls -all
运行 .sh
以运行 hello.sh 为例:
一、直接./加上文件名.sh,如运行hello.sh为./hello.sh【hello.sh必须有x权限】
chmod u+x hello.sh ./hello.sh
二、直接sh 加上文件名.sh,如运行hello.sh为sh hello.sh【hello.sh可以没有x权限】
sh hello.sh
三、绝对路径执行 .sh
这样
/home/hello.sh
或者
./home/hello.sh
或者
sh /home/hello.sh
应用场景
wiki/linux/sh-run.txt · 最后更改: 2023/01/03 15:25 由 127.0.0.1
评论