当前位置:网站首页>如何运行.sh脚本文件
如何运行.sh脚本文件
2022-07-17 16:00:00 【Prada-8808】
最近在学习shell脚本文件时碰到了一个很尴尬的事情,就是脚本会写了,可是该怎么运行呢,于是我就翻阅了手册,查了一些资料
linux下面用命令执行.sh文件有两种方法:
一、直接./加上文件名.sh,如运行hello.sh为./hello.sh【hello.sh必须有x权限】
二、直接sh 加上文件名.sh,如运行hello.sh为sh hello.sh【hello.sh可以没有x权限】
方法一:当前目录执行.sh文件
【步骤一】cd到.sh文件所在目录
【步骤二】给.sh文件添加x执行权限
比如以hello.sh文件为例,
chmod u+x hello.sh【步骤三】./执行.sh文件
比如以hello.sh文件为例,
终端执行以下命令:
./hello.sh即可执行hello.sh文件
【步骤二(2)】sh 执行.sh文件
以hello.sh文件为例,sh hello.sh即可执行hello.sh文件。
sh hello.sh方法二:绝对路径执行.sh文件
下面三种方法都可以:
1 ./home/test/shell/hello.sh
2 /home/test/shell/hello.sh
3 sh /home/test/shell/hello.sh注意事项
用“./”加文件名.sh执行时,必须给.sh文件加x执行权限。
边栏推荐
- Research on Wenhua commodity index
- Choice is more important than effort
- 【嵌入式单元测试】C语言单元测试框架搭建
- C# . Net Yunnan rural credit national secret signature (SM2) brief analysis
- getchar()
- Lychee sound quality high fidelity AI noise reduction technology sharing
- Ten minutes from pytorch to mxnet
- Redis分布式緩存-Redis集群
- 【C语言编程7】BTB模型
- Leetcode 239. 滑动窗口最大值
猜你喜欢
随机推荐
QT learning diary 17 - QT database
Genesis与BlueRun Ventures展开深度交流
李宏毅《机器学习》|1. Introduction of this course(机器学习介绍)
FreeRTOS personal notes - protection of critical values
C语言绘图示例-调色板
Opencv draw a black rectangle and write the serial number
The underlying principle of file operation (inode and hard and soft links, time attributes of files)
Project construction depends on people, and success depends on people!
C language drawing example - palette
2022.07.14 summer training personal qualifying (IX)
Microcomputer principle and technical interface experiment five basic IO operation temperature control experiment
[MySQL] add, delete, check and modify MySQL (Advanced)
数字化转型的两种误区
Three. JS basic element usage
Valid bracket sequence of "Niuke | daily question"
熟悉NestJS (新手篇)
Configuring OSPF experiment in mGRE environment
LeetCode刷题——查找和最小的 K 对数字#373#Medium
HCIP (7)
Region performance tuning









