雏形展示
This commit is contained in:
44
content/小白手册/第一章/1.2.md
Executable file
44
content/小白手册/第一章/1.2.md
Executable file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: "1.2 shell脚本"
|
||||
date: 2021-10-18T16:59:28+08:00
|
||||
draft: false
|
||||
---
|
||||
|
||||
#
|
||||
|
||||
第二节--shell脚本
|
||||
|
||||
上一节讲到了shell,一般来讲,我们使用一两条命令就可以了解决好多事情,但有的时候,需要n条命令才可以解决一个问题,如果它需要重复执行,他就像老太太的裹脚布又臭又长,这谁能顶得住?
|
||||
|
||||
既然像裹脚布,那么我们就要写脚本!
|
||||
|
||||
所有脚本都要写在 .sh文件
|
||||
|
||||
`#!/bin/bash`这一行是声明,shell要用bin下的bash来解释他.
|
||||
|
||||
写注释可以用#
|
||||
|
||||
比如我们可以再桌面上创建一个test.sh然后这样写
|
||||
|
||||
```bash
|
||||
#!bin/bash
|
||||
#this is test.sh
|
||||
echo "I love DOSUCommunity"
|
||||
echo "this is my favorite community"
|
||||
```
|
||||
|
||||
写完之后就可以了运行了
|
||||
|
||||
`momen@momen-PC:~/Desktop$ sh test.sh`
|
||||
|
||||
然后就会输出
|
||||
|
||||
```shell
|
||||
momen@momen-PC:~/Desktop$ sh test.sh
|
||||
I love DOSUCommunity
|
||||
this is my favorite community
|
||||
```
|
||||
|
||||
是不是很简单呢?
|
||||
|
||||
(未完待续)
|
||||
Reference in New Issue
Block a user