update docs
parent
68e2da1820
commit
34458c1c1c
|
@ -1,30 +1,27 @@
|
|||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# http://editorconfig.org
|
||||
# 所有文件换行以 Unix like 风格(LF),win 格式特定的除外(bat)
|
||||
# 缩进 java 4 个空格,其他所有文件 2 个空格
|
||||
# EditorConfig 用于在 IDE 中检查代码的基本 Code Style
|
||||
# @see: https://editorconfig.org/
|
||||
|
||||
# 配置说明:
|
||||
# 所有文件换行使用 Unix 风格(LF),*.bat 文件使用 Windows 风格(CRLF)
|
||||
# java / sh 文件缩进 4 个空格,其他所有文件缩进 2 个空格
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
# Unix-style newlines with a newline ending every file
|
||||
end_of_line = lf
|
||||
|
||||
# Change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# We recommend you to keep these unchanged
|
||||
indent_style = tab
|
||||
max_line_length = 120
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.bat]
|
||||
[*.{bat, cmd}]
|
||||
end_of_line = crlf
|
||||
|
||||
[*.{java, sh}]
|
||||
indent_style = tab
|
||||
[*.{java, groovy, kt, sh}]
|
||||
indent_size = 4
|
||||
|
||||
[*.md]
|
||||
max_line_length = 0
|
||||
trim_trailing_whitespace = false
|
||||
|
|
|
@ -70,6 +70,8 @@
|
|||
*.pdf binary
|
||||
*.doc binary
|
||||
*.docx binary
|
||||
*.ppt binary
|
||||
*.pptx binary
|
||||
*.xls binary
|
||||
*.xlsx binary
|
||||
*.xmind binary
|
||||
|
|
|
@ -1,8 +1,42 @@
|
|||
################ JAVASCRIPT ################
|
||||
# ---------------------------------------------------------------------
|
||||
# more gitignore templates see https://github.com/github/gitignore
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
# ------------------------------- java -------------------------------
|
||||
# compiled folders
|
||||
classes
|
||||
target
|
||||
logs
|
||||
.mtj.tmp/
|
||||
|
||||
# compiled files
|
||||
*.class
|
||||
|
||||
# bluej files
|
||||
*.ctxt
|
||||
|
||||
# package files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs
|
||||
hs_err_pid*
|
||||
|
||||
# maven plugin temp files
|
||||
.flattened-pom.xml
|
||||
|
||||
|
||||
# ------------------------------- javascript -------------------------------
|
||||
# dependencies
|
||||
node_modules
|
||||
|
||||
# temp folders
|
||||
build
|
||||
dist
|
||||
_book
|
||||
_jsdoc
|
||||
|
@ -15,11 +49,11 @@ yarn-error.log*
|
|||
bundle*.js
|
||||
|
||||
|
||||
################ IDEA ################
|
||||
# ------------------------------- intellij -------------------------------
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
|
||||
################ Eclipse ################
|
||||
# ------------------------------- eclipse -------------------------------
|
||||
.classpath
|
||||
.project
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# Linux 教程
|
||||
|
||||
> :keyboard: 项目同步维护在 [github](https://github.com/dunwu/linux-tutorial) | [gitee](https://gitee.com/turnon/linux-tutorial)
|
||||
> 🔁 项目同步维护在 [github](https://github.com/dunwu/linux-tutorial) | [gitee](https://gitee.com/turnon/linux-tutorial)
|
||||
>
|
||||
> 📖 [电子书](https://dunwu.github.io/linux-tutorial/) | [电子书(国内)](http://turnon.gitee.io/linux-tutorial/)
|
||||
|
||||
| :wrench: | :shell: | :memo: | :books: |
|
||||
| :wrench: | :shell: | :memo: | 📚 |
|
||||
| :-------------------: | :-------------------: | :---------------: | :-------------------: |
|
||||
| [软件运维](#软件运维) | [运维和脚本](#运维和脚本) | [知识点](#知识点) | [学习资源](#学习资源) |
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# Linux 教程
|
||||
|
||||
> :keyboard: 项目同步维护在 [github](https://github.com/dunwu/linux-tutorial) | [gitee](https://gitee.com/turnon/linux-tutorial)
|
||||
> 🔁 项目同步维护在 [github](https://github.com/dunwu/linux-tutorial) | [gitee](https://gitee.com/turnon/linux-tutorial)
|
||||
>
|
||||
> 📖 [电子书](https://dunwu.github.io/linux-tutorial/) | [电子书(国内)](http://turnon.gitee.io/linux-tutorial/)
|
||||
|
||||
| :wrench: | :shell: | :memo: | :books: |
|
||||
| :wrench: | :shell: | :memo: | 📚 |
|
||||
| :-------------------: | :-------------------: | :---------------: | :-------------------: |
|
||||
| [软件运维](#软件运维) | [运维和脚本](#运维和脚本) | [知识点](#知识点) | [学习资源](#学习资源) |
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div align="center"><img width="100px" src="http://dunwu.test.upcdn.net/common/logo/zp.png"/></div>
|
||||
|
||||
# Linux Tutorial
|
||||
# linux-tutorial
|
||||
|
||||
> Linux 教程
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
- [git-flow 工作流](git-flow.md)
|
||||
- [Git 常见问题](git-faq.md)
|
||||
|
||||
## :books: 学习资源
|
||||
## 📚 学习资源
|
||||
|
||||
### 官方资源
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Linux Tutorial</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="description" content="Linux 教程" />
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
|
||||
<meta content="Linux 教程" name="description"/>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
|
||||
name="viewport"
|
||||
/>
|
||||
<link rel="icon" href="http://dunwu.test.upcdn.net/common/logo/zp_50_50.png" type="image/x-icon" />
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css" title="vue" />
|
||||
<link href="http://dunwu.test.upcdn.net/common/logo/zp_50_50.png" rel="icon" type="image/x-icon"/>
|
||||
<link href="//unpkg.com/docsify/lib/themes/vue.css" rel="stylesheet" title="vue"/>
|
||||
<style>
|
||||
h1 + ul {
|
||||
display: block !important;
|
||||
|
@ -28,20 +28,20 @@
|
|||
.sidebar-toggle,
|
||||
body,
|
||||
.search input {
|
||||
color: #6b615f !important;
|
||||
background-color: #fff4e6 !important;
|
||||
color: #6B615F !important;
|
||||
background-color: #FFF4E6 !important;
|
||||
}
|
||||
|
||||
.content strong,
|
||||
.sidebar strong,
|
||||
body strong {
|
||||
color: #5c5869 !important;
|
||||
color: #5C5869 !important;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.cover-main .anchor span {
|
||||
text-align: center;
|
||||
background-image: -webkit-linear-gradient(left, #ffdcb4, #b96972 25%, #e88a57 50%, #804170 75%, #a596cd);
|
||||
background-image: -webkit-linear-gradient(left, #FFDCB4, #B96972 25%, #E88A57 50%, #804170 75%, #A596CD);
|
||||
-webkit-text-fill-color: transparent;
|
||||
-webkit-background-clip: text;
|
||||
-webkit-background-size: 200% 100%;
|
||||
|
@ -51,17 +51,17 @@
|
|||
}
|
||||
|
||||
.cover-main blockquote p {
|
||||
color: #5c5869;
|
||||
color: #5C5869;
|
||||
font-family: "Arial", 隶书, serif;
|
||||
}
|
||||
|
||||
.cover-main ul a:hover {
|
||||
color: #fe4165 !important;
|
||||
color: #FE4165 !important;
|
||||
}
|
||||
|
||||
.cover-main p a:hover {
|
||||
text-align: center;
|
||||
background-image: -webkit-linear-gradient(left, #ffdcb4, #b96972 25%, #e88a57 50%, #804170 75%, #a596cd);
|
||||
background-image: -webkit-linear-gradient(left, #FFDCB4, #B96972 25%, #E88A57 50%, #804170 75%, #A596CD);
|
||||
-webkit-text-fill-color: transparent;
|
||||
-webkit-background-clip: text;
|
||||
-webkit-background-size: 200% 100%;
|
||||
|
@ -71,13 +71,13 @@
|
|||
/* content 样式内容 */
|
||||
.sidebar a,
|
||||
.content a {
|
||||
color: #399ab2 !important;
|
||||
color: #399AB2 !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.sidebar a:hover,
|
||||
.content a:hover {
|
||||
color: #fe4165 !important;
|
||||
color: #FE4165 !important;
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@
|
|||
.content h3 :hover,
|
||||
.content h4 :hover {
|
||||
text-align: center;
|
||||
background-image: -webkit-linear-gradient(left, #ffdcb4, #b96972 25%, #e88a57 50%, #804170 75%, #a596cd);
|
||||
background-image: -webkit-linear-gradient(left, #FFDCB4, #B96972 25%, #E88A57 50%, #804170 75%, #A596CD);
|
||||
-webkit-text-fill-color: transparent;
|
||||
-webkit-background-clip: text;
|
||||
-webkit-background-size: 200% 100%;
|
||||
|
@ -106,14 +106,14 @@
|
|||
|
||||
.content h1 a,
|
||||
.content h1 span {
|
||||
color: #399ab2 !important;
|
||||
color: #399AB2 !important;
|
||||
font-size: 30px;
|
||||
text-shadow: 2px 2px 5px grey;
|
||||
}
|
||||
|
||||
.content h2 a,
|
||||
.content h2 span {
|
||||
color: #60497c !important;
|
||||
color: #60497C !important;
|
||||
font-size: 26px;
|
||||
text-shadow: 2px 2px 5px grey;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@
|
|||
.content h4 a,
|
||||
.content h4 span {
|
||||
font-size: 18px;
|
||||
color: #78943a;
|
||||
color: #78943A;
|
||||
text-shadow: 2px 2px 5px grey;
|
||||
}
|
||||
|
||||
|
@ -147,8 +147,8 @@
|
|||
.content blockquote {
|
||||
display: block;
|
||||
padding: 0 16px;
|
||||
border-left: 8px solid #dddfe4;
|
||||
background: #fff2c9;
|
||||
border-left: 8px solid #DDDFE4;
|
||||
background: #FFF2C9;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@
|
|||
padding-left: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
border-radius: 8px;
|
||||
box-shadow: 1px 1px 20px 3px #dddddd !important;
|
||||
box-shadow: 1px 1px 20px 3px #DDDDDD !important;
|
||||
}
|
||||
|
||||
.content code {
|
||||
|
@ -169,13 +169,13 @@
|
|||
display: table;
|
||||
padding-left: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
box-shadow: 2px 2px 20px 6px #dddddd !important;
|
||||
box-shadow: 2px 2px 20px 6px #DDDDDD !important;
|
||||
}
|
||||
|
||||
.content th {
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
background-color: #cce6b6;
|
||||
background-color: #CCE6B6;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
|
@ -209,37 +209,34 @@
|
|||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">正在加载...</div>
|
||||
<script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">正在加载...</div>
|
||||
<script>
|
||||
window.$docsify = {
|
||||
name: "Linux Tutorial",
|
||||
repo: "https://github.com/dunwu/linux-tutorial",
|
||||
logo: "http://dunwu.test.upcdn.net/common/logo/zp_100_100.png",
|
||||
name: 'Linux Tutorial',
|
||||
repo: 'https://github.com/dunwu/linux-tutorial',
|
||||
logo: 'http://dunwu.test.upcdn.net/common/logo/zp_100_100.png',
|
||||
auto2top: true,
|
||||
coverpage: "coverpage.md",
|
||||
coverpage: 'coverpage.md',
|
||||
maxLevel: 4,
|
||||
subMaxLevel: 4,
|
||||
formatUpdated: "{MM}/{DD} {HH}:{mm}",
|
||||
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||
search: {
|
||||
maxAge: 86400000,
|
||||
paths: ["/"],
|
||||
placeholder: "🔍 搜索",
|
||||
noData: "没有结果!",
|
||||
depth: 4
|
||||
maxAge: 86400000, paths: ['/'], placeholder: '🔍 搜索', noData: '没有结果!', depth: 4
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/emoji.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/search.js"></script>
|
||||
}
|
||||
</script>
|
||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/emoji.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/search.js"></script>
|
||||
|
||||
<!--代码高亮-->
|
||||
<script src="//unpkg.com/prismjs/components/prism-basic.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-java.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
|
||||
</body>
|
||||
<!--代码高亮-->
|
||||
<!--@see https://github.com/PrismJS/prism -->
|
||||
<script src="//unpkg.com/prismjs/components/prism-basic.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-java.min.js"></script>
|
||||
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -250,7 +250,7 @@ touch ex2
|
|||
|
||||
> ln 命令用来为文件创建连接,连接类型分为硬连接和符号连接两种,默认的连接类型是硬连接。如果要创建符号连接必须使用"-s"选项。
|
||||
>
|
||||
> 注意:符号链接文件不是一个独立的文件,它的许多属性依赖于源文件,所以给符号链接文件设置存取权限是没有意义的。
|
||||
> 🔔 注意:符号链接文件不是一个独立的文件,它的许多属性依赖于源文件,所以给符号链接文件设置存取权限是没有意义的。
|
||||
>
|
||||
> 参考:http://man.linuxde.net/ln
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ yum 的默认源是国外的,下载速度比较慢,所以最好替换为一
|
|||
| <http://mirrors.163.com/> | Centos6:http://mirrors.aliyun.com/repo/Centos-6.repo<br>Centos7:http://mirrors.aliyun.com/repo/Centos-7.repo |
|
||||
| <http://mirrors.aliyun.com/> | Centos6:http://mirrors.163.com/.help/CentOS6-Base-163.repo<br>Centos7:http://mirrors.163.com/.help/CentOS7-Base-163.repo |
|
||||
|
||||
> 注意:Cento5 已废弃,只能使用 http://vault.centos.org/ 替换,但由于是国外镜像,速度较慢。
|
||||
> 🔔 注意:Cento5 已废弃,只能使用 http://vault.centos.org/ 替换,但由于是国外镜像,速度较慢。
|
||||
|
||||
替换方法,以 aliyun CentOS7 为例:
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ date: 2019-03-06
|
|||
|
||||
# Linux 典型运维应用
|
||||
|
||||
> :bulb: 如果没有特殊说明,本文的案例都是针对 Centos 发行版本。
|
||||
> 💡 如果没有特殊说明,本文的案例都是针对 Centos 发行版本。
|
||||
|
||||
## 网络操作
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
> 本文主要介绍 bash 的语法,对于 linux 指令不做任何介绍。
|
||||
>
|
||||
> :notebook: 本文已归档到:「[blog](https://github.com/dunwu/blog)」
|
||||
> :keyboard: 本文的源码已归档到 [linux-tutorial](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos)
|
||||
> 🔁 本文的源码已归档到 [linux-tutorial](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos)
|
||||
|
||||
```
|
||||
███████╗██╗ ██╗███████╗██╗ ██╗
|
||||
|
@ -173,7 +173,7 @@ chmod +x /path/to/script.sh #使脚本具有执行权限
|
|||
|
||||
这种方式要求脚本文件的第一行必须指明运行该脚本的程序,比如:
|
||||
|
||||
**:keyboard: 『示例源码』** [helloworld.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/helloworld.sh)
|
||||
**🔁 『示例源码』** [helloworld.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/helloworld.sh)
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
|
@ -207,7 +207,7 @@ shell 语法中,注释是特殊的语句,会被 shell 解释器忽略。
|
|||
- 单行注释 - 以 `#` 开头,到行尾结束。
|
||||
- 多行注释 - 以 `:<<EOF` 开头,到 `EOF` 结束。
|
||||
|
||||
**:keyboard: 『示例源码』** [comment-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/comment-demo.sh)
|
||||
**🔁 『示例源码』** [comment-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/comment-demo.sh)
|
||||
|
||||
```bash
|
||||
#--------------------------------------------
|
||||
|
@ -293,7 +293,7 @@ echo `pwd`
|
|||
# Output:(当前目录路径)
|
||||
```
|
||||
|
||||
**:keyboard: 『示例源码』** [echo-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/echo-demo.sh)
|
||||
**🔁 『示例源码』** [echo-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/echo-demo.sh)
|
||||
|
||||
### 2.4. printf
|
||||
|
||||
|
@ -301,7 +301,7 @@ printf 用于格式化输出字符串。
|
|||
|
||||
默认,printf 不会像 echo 一样自动添加换行符,如果需要换行可以手动添加 `\n`。
|
||||
|
||||
**:keyboard: 『示例源码』** [printf-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/printf-demo.sh)
|
||||
**🔁 『示例源码』** [printf-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/printf-demo.sh)
|
||||
|
||||
```bash
|
||||
# 单引号
|
||||
|
@ -619,7 +619,7 @@ echo ${nums[@]}
|
|||
|
||||
### 5.6. 数组示例源码
|
||||
|
||||
**:keyboard: 『示例源码』** [array-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/array-demo.sh)
|
||||
**🔁 『示例源码』** [array-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos/array-demo.sh)
|
||||
|
||||
## 6. 运算符
|
||||
|
||||
|
@ -640,7 +640,7 @@ echo ${nums[@]}
|
|||
|
||||
**注意:**条件表达式要放在方括号之间,并且要有空格,例如: `[$x==$y]` 是错误的,必须写成 `[ $x == $y ]`。
|
||||
|
||||
**:keyboard: 『示例源码』** [operator-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo.sh)
|
||||
**🔁 『示例源码』** [operator-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo.sh)
|
||||
|
||||
```bash
|
||||
x=10
|
||||
|
@ -698,7 +698,7 @@ fi
|
|||
| `-ge` | 检测左边的数是否大于等于右边的,如果是,则返回 true。 | `[ $a -ge $b ]` 返回 false。 |
|
||||
| `-le` | 检测左边的数是否小于等于右边的,如果是,则返回 true。 | `[ $a -le $b ]`返回 true。 |
|
||||
|
||||
**:keyboard: 『示例源码』** [operator-demo2.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo2.sh)
|
||||
**🔁 『示例源码』** [operator-demo2.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo2.sh)
|
||||
|
||||
```bash
|
||||
x=10
|
||||
|
@ -763,7 +763,7 @@ fi
|
|||
| `-o` | 或运算,有一个表达式为 true 则返回 true。 | `[ $a -lt 20 -o $b -gt 100 ]` 返回 true。 |
|
||||
| `-a` | 与运算,两个表达式都为 true 才返回 true。 | `[ $a -lt 20 -a $b -gt 100 ]` 返回 false。 |
|
||||
|
||||
**:keyboard: 『示例源码』** [operator-demo3.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo3.sh)
|
||||
**🔁 『示例源码』** [operator-demo3.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo3.sh)
|
||||
|
||||
```bash
|
||||
x=10
|
||||
|
@ -813,7 +813,7 @@ fi
|
|||
| `&&` | 逻辑的 AND | `[[ ${x} -lt 100 && ${y} -gt 100 ]]` 返回 false |
|
||||
| `||` | 逻辑的 OR | `[[ ${x} -lt 100 || ${y} -gt 100 ]]` 返回 true |
|
||||
|
||||
**:keyboard: 『示例源码』** [operator-demo4.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo4.sh)
|
||||
**🔁 『示例源码』** [operator-demo4.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo4.sh)
|
||||
|
||||
```bash
|
||||
x=10
|
||||
|
@ -854,7 +854,7 @@ fi
|
|||
| `-n` | 检测字符串长度是否为 0,不为 0 返回 true。 | `[ -n $a ]` 返回 true。 |
|
||||
| `str` | 检测字符串是否为空,不为空返回 true。 | `[ $a ]` 返回 true。 |
|
||||
|
||||
**:keyboard: 『示例源码』** [operator-demo5.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo5.sh)
|
||||
**🔁 『示例源码』** [operator-demo5.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo5.sh)
|
||||
|
||||
```bash
|
||||
x="abc"
|
||||
|
@ -925,7 +925,7 @@ fi
|
|||
| -s file | 检测文件是否为空(文件大小是否大于 0),不为空返回 true。 | `[ -s $file ]` 返回 true。 |
|
||||
| -e file | 检测文件(包括目录)是否存在,如果是,则返回 true。 | `[ -e $file ]` 返回 true。 |
|
||||
|
||||
**:keyboard: 『示例源码』** [operator-demo6.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo6.sh)
|
||||
**🔁 『示例源码』** [operator-demo6.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/operator/operator-demo6.sh)
|
||||
|
||||
```bash
|
||||
file="/etc/hosts"
|
||||
|
@ -1036,13 +1036,13 @@ fi
|
|||
# Output: 10 < 20
|
||||
```
|
||||
|
||||
**:keyboard: 『示例源码』** [if-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/if-demo.sh)
|
||||
**🔁 『示例源码』** [if-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/if-demo.sh)
|
||||
|
||||
#### `case`
|
||||
|
||||
如果你需要面对很多情况,分别要采取不同的措施,那么使用`case`会比嵌套的`if`更有用。使用`case`来解决复杂的条件判断,看起来像下面这样:
|
||||
|
||||
**:keyboard: 『示例源码』** [case-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/case-demo.sh)
|
||||
**🔁 『示例源码』** [case-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/case-demo.sh)
|
||||
|
||||
```bash
|
||||
exec
|
||||
|
@ -1114,7 +1114,7 @@ done
|
|||
# 将 /home/zp 目录下所有 sh 文件拷贝到 /home/zp/scripts
|
||||
```
|
||||
|
||||
**:keyboard: 『示例源码』** [for-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/for-demo.sh)
|
||||
**🔁 『示例源码』** [for-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/for-demo.sh)
|
||||
|
||||
#### `while`循环
|
||||
|
||||
|
@ -1151,7 +1151,7 @@ done
|
|||
# 81
|
||||
```
|
||||
|
||||
**:keyboard: 『示例源码』** [while-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/while-demo.sh)
|
||||
**🔁 『示例源码』** [while-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/while-demo.sh)
|
||||
|
||||
#### `until`循环
|
||||
|
||||
|
@ -1171,7 +1171,7 @@ done
|
|||
# 4
|
||||
```
|
||||
|
||||
**:keyboard: 『示例源码』** [until-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/until-demo.sh)
|
||||
**🔁 『示例源码』** [until-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/until-demo.sh)
|
||||
|
||||
#### `select`循环
|
||||
|
||||
|
@ -1219,7 +1219,7 @@ Choose the package manager: 2
|
|||
Enter the package name: gitbook-cli
|
||||
```
|
||||
|
||||
**:keyboard: 『示例源码』** [select-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/select-demo.sh)
|
||||
**🔁 『示例源码』** [select-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/select-demo.sh)
|
||||
|
||||
#### `break` 和 `continue`
|
||||
|
||||
|
@ -1229,7 +1229,7 @@ Enter the package name: gitbook-cli
|
|||
>
|
||||
> `continue`语句用来跳过某次迭代。
|
||||
|
||||
**:keyboard: 『示例源码』** [break-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/break-demo.sh)
|
||||
**🔁 『示例源码』** [break-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/break-demo.sh)
|
||||
|
||||
```bash
|
||||
# 查找 10 以内第一个能整除 2 和 3 的正整数
|
||||
|
@ -1244,7 +1244,7 @@ done
|
|||
# Output: 6
|
||||
```
|
||||
|
||||
**:keyboard: 『示例源码』** [continue-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/continue-demo.sh)
|
||||
**🔁 『示例源码』** [continue-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/statement/continue-demo.sh)
|
||||
|
||||
```bash
|
||||
# 打印10以内的奇数
|
||||
|
@ -1273,14 +1273,14 @@ bash 函数定义语法如下:
|
|||
}
|
||||
```
|
||||
|
||||
> :bulb: 说明:
|
||||
> 💡 说明:
|
||||
>
|
||||
> 1. 函数定义时,`function` 关键字可有可无。
|
||||
> 2. 函数返回值 - return 返回函数返回值,返回值类型只能为整数(0-255)。如果不加 return 语句,shell 默认将以最后一条命令的运行结果,作为函数返回值。
|
||||
> 3. 函数返回值在调用该函数后通过 `$?` 来获得。
|
||||
> 4. 所有函数在使用前必须定义。这意味着必须将函数放在脚本开始部分,直至 shell 解释器首次发现它时,才可以使用。调用函数仅使用其函数名即可。
|
||||
|
||||
**:keyboard: 『示例源码』** [function-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos//function/function-demo.sh)
|
||||
**🔁 『示例源码』** [function-demo.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos//function/function-demo.sh)
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
|
@ -1346,7 +1346,7 @@ the result is: 100
|
|||
| `$#` | 不包括`$0`在内的位置参数的个数 |
|
||||
| `$FUNCNAME` | 函数名称(仅在函数内部有值) |
|
||||
|
||||
**:keyboard: 『示例源码』** [function-demo2.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos//function/function-demo2.sh)
|
||||
**🔁 『示例源码』** [function-demo2.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos//function/function-demo2.sh)
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
|
@ -1406,7 +1406,7 @@ $ ./function-demo2.sh 10 20
|
|||
| `$-` | 返回 Shell 使用的当前选项,与 set 命令功能相同。 |
|
||||
| `$?` | 函数返回值 |
|
||||
|
||||
**:keyboard: 『示例源码』** [function-demo3.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos//function/function-demo3.sh)
|
||||
**🔁 『示例源码』** [function-demo3.sh](https://github.com/dunwu/linux-tutorial/tree/master/codes/shell/demos//function/function-demo3.sh)
|
||||
|
||||
```bash
|
||||
runner() {
|
||||
|
@ -1644,7 +1644,7 @@ $ ./my_script
|
|||
|
||||
有时我们值需要 debug 脚本的一部分。这种情况下,使用`set`命令会很方便。这个命令可以启用或禁用选项。使用`-`启用选项,`+`禁用选项:
|
||||
|
||||
**:keyboard: 『示例源码』** [debug-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/debug-demo.sh)
|
||||
**🔁 『示例源码』** [debug-demo.sh](https://github.com/dunwu/linux-tutorial/blob/master/codes/shell/demos/debug-demo.sh)
|
||||
|
||||
```bash
|
||||
# 开启 debug
|
||||
|
|
|
@ -190,7 +190,7 @@ Nexus 中的仓库有以下类型:
|
|||
</distributionManagement>
|
||||
```
|
||||
|
||||
> 注意:
|
||||
> 🔔 注意:
|
||||
>
|
||||
> - `<repository>` 和 `<snapshotRepository>` 的 id 必须和 `settings.xml` 配置文件中的 `<server>` 标签中的 id 匹配。
|
||||
> - `<url>` 标签的地址需要和 maven 私服的地址匹配。
|
||||
|
|
|
@ -314,7 +314,7 @@ Cmd+C、Cmd+V、Cmd+X、Cmd+A、Cmd+Z。
|
|||
|
||||
打开 CheatSheet 后,长按 command 键,会弹出当前应用程序的所有快捷键。我们还可以对这些快捷键进行保存。
|
||||
|
||||
## :books: 学习资源
|
||||
## 📚 学习资源
|
||||
|
||||
- [Awesome Mac](https://github.com/jaywcjlove/awesome-mac)
|
||||
- [awesome-macos-command-line](https://github.com/herrbischoff/awesome-macos-command-line)
|
||||
|
|
Loading…
Reference in New Issue