Skip to content

Commit

Permalink
chore: format markdown code. (jaywcjlove#42)
Browse files Browse the repository at this point in the history
* format: fix markdown

* update: fix markdown

* update: fix cron problems

* update: delete .markdownlintignore

* update

* chore: add tab -> 4 space

* chore: fix tab -> 2 in the .editorconfig
  • Loading branch information
fwqaaq authored Nov 10, 2022
1 parent ea80136 commit 5701da6
Show file tree
Hide file tree
Showing 88 changed files with 1,075 additions and 1,126 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[./docs/*.md]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"**/*.{mjs,css,json,prettierrc,lintstagedrc}": ["prettier --write"],
"./docs/*.md": ["markdownlint --fix ./docs"]
"./docs/*.md": ["npx markdownlint-cli --fix ./docs"]
}
6 changes: 5 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"MD014": false,
"MD024": false,
"MD033": false,
"MD040": false
"MD040": false,
"MD010": {
"code_blocks": true,
"spaces_per_tab": 4
}
}
21 changes: 10 additions & 11 deletions docs/ansible.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Ansible 备忘清单

- [Ansible 官方文档](https://docs.ansible.com)


### 配置位置

文件路径 | 说明
Expand All @@ -27,7 +26,6 @@ Ansible 备忘清单
`~/ansible.cfg` | 用户特定的配置
`$pwd/ansible.cfg` | 当前目录下的配置


### Inventory文件(hosts列表)

#### 静态Inventory
Expand Down Expand Up @@ -86,6 +84,7 @@ proxy=proxy.atlanta.example.com
```shell
$ ansible all --list-hosts
```

ping所有目标

```shell
Expand All @@ -108,19 +107,19 @@ $ ansible all -i localhost, -e '{"ansible_connection": "local"}' -a 'hostname'

```shell
$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -m setup
```
```
<!--rehype:className=wrap-text -->
获取远程到本地

```shell
$ ansible target -m fetch -a "src=/tmp/seq dest=/tmp/seq"
```
```
<!--rehype:className=wrap-text -->
拷贝本地到远程

```shell
$ ansible target -m copy -a "src=/tmp/seq dest=/tmp/seq"
```
```
<!--rehype:className=wrap-text -->

### Ansible 命令帮助
Expand All @@ -131,7 +130,7 @@ $ ansible
$ ansible <host-pattern> [options]
```

----
---

:- | -
:- | -
Expand Down Expand Up @@ -219,7 +218,6 @@ $ ansible-galaxy init --offline <ROLE>
```
<!--rehype:className=wrap-text-->


### ansible-doc

在本地访问文档
Expand All @@ -241,13 +239,13 @@ $ ansible-doc [options] [module...]
`--version` | 显示程序的版本号并退出
<!--rehype:className=style-list-->


### ansible-vault

```bash
$ ansible-vault
$ ansible-vault [create|decrypt|edit|encrypt|rekey|view] [--help] [options] vaultfile.yml
```

---

:- | -
Expand All @@ -268,6 +266,7 @@ $ ansible-vault [create|decrypt|edit|encrypt|rekey|view] [--help] [options] vaul
$ ansible-playbook
$ ansible-playbook playbook.yml
```

---

:- | -
Expand Down Expand Up @@ -329,13 +328,14 @@ $ ansible-playbook playbook.yml
`-K`, `--ask-become-pass` | 要求提权密码
<!--rehype:className=style-list-->

### ansible-pull
### ansible-pull
<!--rehype:wrap-class=row-span-2-->

```bash
$ ansible-pull
$ ansible-pull -U <repository> [options]
```

---

:- | -
Expand Down Expand Up @@ -394,10 +394,9 @@ $ ansible-pull -U <repository> [options]
<!-- ### ansible-playbook -->
<!-- todo -->



另见
---

[Getting started with Ansible](https://docs.ansible.com/ansible/latest/getting_started/index.html)
[Introduction to ad hoc commands](https://docs.ansible.com/ansible/latest/user_guide/intro_adhoc.html)
[Ansible cheatsheet](https://github.com/luckylittle/ansible-cheatsheet/blob/master/ansible-cheatsheet.txt)
26 changes: 12 additions & 14 deletions docs/awk.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $ awk -F: '{print $1, $NF}' /etc/passwd
| | `$NF` | 最后一个字段 |
| | `/etc/passwd` | 输入数据文件 |

### Awk 程序
### Awk 程序

```bash
BEGIN {<初始化>}
Expand Down Expand Up @@ -59,7 +59,8 @@ $0/NR ▶ │ 1 │ baidu.com │ awk │
$0/NR ▶ │ 2 │ google.com │ 25 │
└──────┴──────────────┴───────┘
```
---

----

```shell
# 第一个和最后一个字段
Expand Down Expand Up @@ -253,7 +254,6 @@ awk -v varName="$PWD" '
END {print varName}' </dev/null
```


Awk 运算符
---------

Expand Down Expand Up @@ -291,17 +291,17 @@ Awk 运算符
- `*`
- `/`
- `%`
- `++`
- `--`
- `++`
- `--`
<!--rehype:className=cols-3 style-none-->

#### 速记作业

- `+=`
- `-=`
- `*=`
- `/=`
- `%=`
- `+=`
- `-=`
- `*=`
- `/=`
- `%=`
<!--rehype:className=cols-3 style-none-->

#### 比较运算符
Expand Down Expand Up @@ -366,7 +366,6 @@ Awk 函数
`toupper(s)` | 字符串 `s` 转大写
`getline` | 将 `$0` 设置为当前输入文件中的下一个输入记录


### 用户定义函数

```shell
Expand Down Expand Up @@ -424,7 +423,6 @@ awk 'BEGIN {
}'
```


### 带拆分的数组

```shell
Expand Down Expand Up @@ -536,7 +534,6 @@ awk -F: '{
}' /etc/passwd
```


Awk 循环
----------

Expand Down Expand Up @@ -744,6 +741,7 @@ daemon /sbin
-------------

### 正则表达式元字符

- `\`
- `^`
- `$`
Expand Down Expand Up @@ -785,4 +783,4 @@ $ awk -f demo.awk /etc/passwd
--------
- [GNU awk 用户指南](https://www-zeuthen.desy.de/dv/documentation/unixguide/infohtml/gawk/gawk.html) _(www-zeuthen.desy.de)_
- [AWK cheatsheet](https://gist.github.com/Rafe/3102414) _(gist.github.com)_
- [AWK cheatsheet](https://gist.github.com/Rafe/3102414) _(gist.github.com)_
55 changes: 24 additions & 31 deletions docs/bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ NAME = "John" # => Error (关于空间)

见:[特殊参数](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables)


### 函数

```bash
Expand Down Expand Up @@ -204,7 +203,7 @@ DIRPATH=${SRC%$BASEPATH}
echo $DIRPATH # => "/path/to/"
```

### Transform
### Transform

```bash
STR="HELLO WORLD!"
Expand All @@ -220,7 +219,7 @@ echo "${ARR[@],}" # => hello world
echo "${ARR[@]^}" # => Hello World
```

Bash 数组
Bash 数组
------

### 定义数组
Expand All @@ -247,14 +246,14 @@ Numbers+=(4 5) # 附加 => 1 2 3 4 5

:- | -
:- | -
`${Fruits[0]}` | 第一个元素
`${Fruits[-1]}` | 最后一个元素
`${Fruits[*]}` | 所有元素
`${Fruits[@]}` | 所有元素
`${#Fruits[@]}` | 总数
`${#Fruits}` | 第一节长度
`${#Fruits[3]}` | 第n个长度
`${Fruits[@]:3:2}` | 范围
`${Fruits[0]}` | 第一个元素
`${Fruits[-1]}` | 最后一个元素
`${Fruits[*]}` | 所有元素
`${Fruits[@]}` | 所有元素
`${#Fruits[@]}` | 总数
`${#Fruits}` | 第一节长度
`${#Fruits[3]}` | 第n个长度
`${Fruits[@]:3:2}` | 范围
`${!Fruits[@]}` | 所有 Key

### 迭代 Iteration
Expand All @@ -265,7 +264,9 @@ for e in "${Fruits[@]}"; do
echo $e
done
```

#### With index

```bash
for i in "${!Fruits[@]}"; do
printf "%s\t%s\n" "$i" "${Fruits[$i]}"
Expand Down Expand Up @@ -443,15 +444,14 @@ fi
`[[ f1 -ot f2 ]]` | f2 早于 f1
`[[ f1 -ef f2 ]]` | 相同的文件


### 更多条件

条件 | 描述
:- | -
`[[ -o noclobber ]]` | 如果启用 OPTION
`[[ ! EXPR ]]` | 不是 Not
`[[ X && Y ]]` | 和 And
`[[ X \|\| Y ]]` | 或者 Or
`[[ X \|\| Y ]]` | 或者 Or

### 逻辑和,或

Expand Down Expand Up @@ -554,7 +554,7 @@ until [ $count -gt 10 ]; do
done
```

### 永远
### 永远

```bash
while true; do
Expand All @@ -570,7 +570,6 @@ while :; do
done
```


### 正在读取行

```bash
Expand Down Expand Up @@ -720,8 +719,7 @@ Bash 历史

`!!` 可以替换为任何有效的扩展,即 `!cat``!-2``!42` 等。


各种各样的
各种各样的
-------------

### 数值计算
Expand All @@ -741,7 +739,6 @@ $(($RANDOM%200)) # Random number 0..199
pwd # still in first directory
```


### 检查命令

```bash
Expand All @@ -765,7 +762,6 @@ python hello.py &>/dev/null # 标准输出和标准错误到(空null)
python hello.py < foo.txt # 将 foo.txt 提供给 python 的标准输入
```


### 来源相对

```bash
Expand All @@ -791,7 +787,6 @@ case "$1" in
esac
```


### 陷阱错误
<!--rehype:wrap-class=col-span-2-->

Expand Down Expand Up @@ -862,7 +857,6 @@ fi

[特殊参数](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables)


### grep 检查
<!--rehype:wrap-class=col-span-2-->

Expand All @@ -872,11 +866,10 @@ if grep -q 'foo' ~/.bash_history; then
fi
```


### 反斜杠转义
<!--rehype:wrap-class=row-span-2-->

- &nbsp;
- &nbsp;
- \!
- \"
- \#
Expand Down Expand Up @@ -963,11 +956,11 @@ echo "${args[@]}"
另见
----

* [Shell 教程](https://jaywcjlove.github.io/shell-tutorial) _(jaywcjlove.github.io)_
* [Devhints](https://devhints.io/bash) _(devhints.io)_
* [Bash-hackers wiki](http://wiki.bash-hackers.org/) _(bash-hackers.org)_
* [Shell vars](http://wiki.bash-hackers.org/syntax/shellvars) _(bash-hackers.org)_
* [Learn bash in y minutes](https://learnxinyminutes.com/docs/bash/) _(learnxinyminutes.com)_
* [Bash Guide](http://mywiki.wooledge.org/BashGuide) _(mywiki.wooledge.org)_
* [ShellCheck](https://www.shellcheck.net/) _(shellcheck.net)_
* [shell - Standard Shell](https://devmanual.gentoo.org/tools-reference/bash/index.html) _(devmanual.gentoo.org)_
- [Shell 教程](https://jaywcjlove.github.io/shell-tutorial) _(jaywcjlove.github.io)_
- [Devhints](https://devhints.io/bash) _(devhints.io)_
- [Bash-hackers wiki](http://wiki.bash-hackers.org/) _(bash-hackers.org)_
- [Shell vars](http://wiki.bash-hackers.org/syntax/shellvars) _(bash-hackers.org)_
- [Learn bash in y minutes](https://learnxinyminutes.com/docs/bash/) _(learnxinyminutes.com)_
- [Bash Guide](http://mywiki.wooledge.org/BashGuide) _(mywiki.wooledge.org)_
- [ShellCheck](https://www.shellcheck.net/) _(shellcheck.net)_
- [shell - Standard Shell](https://devmanual.gentoo.org/tools-reference/bash/index.html) _(devmanual.gentoo.org)_
Loading

0 comments on commit 5701da6

Please sign in to comment.