linux命令怎么运行.sh
时间: 2023-06-11 22:09:00 浏览: 66
要运行一个.sh文件,需要在终端中进入该文件所在的目录,并输入如下命令:
```
./filename.sh
```
其中,filename.sh是你要运行的脚本文件名。运行该命令后,系统会自动执行该脚本文件中的命令。请注意,你需要在文件名前加上"./",否则系统可能无法正确识别文件路径。另外,你需要确保该文件具有可执行权限,可以通过 chmod 命令赋予该文件执行权限。
相关问题
linux后台运行.sh
要在Linux后台运行.sh脚本,可以使用以下命令:
```
nohup /path/to/script.sh > output.log 2>&1 &
```
其中,/path/to/script.sh是你要运行的脚本文件路径,output.log是你要保存输出的日志文件路径。这条命令将会在后台运行脚本,并将输出写入日志文件中。
如果你想在运行脚本时不受当前终端的影响,可以使用disown命令:
```
nohup /path/to/script.sh > output.log 2>&1 & disown
```
这样,即使你关闭了当前终端,脚本也会继续在后台运行。
shell命令运行.SH文件
要运行一个.sh文件,你可以使用以下命令:
sh ./test.sh
这个命令会执行名为test.sh的脚本文件。其中,sh是指调用shell解释器,而./test.sh是指当前目录下的test.sh文件。
在Linux中,有多种不同的Shell可用,如Bourne Shell、Bourne Again Shell、C Shell、K Shell等。不同的Shell有不同的特点和用途。例如,Bourne Shell的路径是/usr/bin/sh或/bin/sh,而Bourne Again Shell的路径是/bin/bash。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [【Linux中shell命令】.sh文件种种操作](https://blog.csdn.net/a_piece_of_ppx/article/details/124929728)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
相关推荐
![sh](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)