mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-16 12:11:21 +08:00
chore: format markdown code. (#42)
* 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
This commit is contained in:
26
docs/awk.md
26
docs/awk.md
@ -25,7 +25,7 @@ $ awk -F: '{print $1, $NF}' /etc/passwd
|
||||
| | `$NF` | 最后一个字段 |
|
||||
| | `/etc/passwd` | 输入数据文件 |
|
||||
|
||||
### Awk 程序
|
||||
### Awk 程序
|
||||
|
||||
```bash
|
||||
BEGIN {<初始化>}
|
||||
@ -59,7 +59,8 @@ $0/NR ▶ │ 1 │ baidu.com │ awk │
|
||||
$0/NR ▶ │ 2 │ google.com │ 25 │
|
||||
└──────┴──────────────┴───────┘
|
||||
```
|
||||
---
|
||||
|
||||
----
|
||||
|
||||
```shell
|
||||
# 第一个和最后一个字段
|
||||
@ -253,7 +254,6 @@ awk -v varName="$PWD" '
|
||||
END {print varName}' </dev/null
|
||||
```
|
||||
|
||||
|
||||
Awk 运算符
|
||||
---------
|
||||
|
||||
@ -291,17 +291,17 @@ Awk 运算符
|
||||
- `*`
|
||||
- `/`
|
||||
- `%`
|
||||
- `++`
|
||||
- `--`
|
||||
- `++`
|
||||
- `--`
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
#### 速记作业
|
||||
|
||||
- `+=`
|
||||
- `-=`
|
||||
- `*=`
|
||||
- `/=`
|
||||
- `%=`
|
||||
- `+=`
|
||||
- `-=`
|
||||
- `*=`
|
||||
- `/=`
|
||||
- `%=`
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
#### 比较运算符
|
||||
@ -366,7 +366,6 @@ Awk 函数
|
||||
`toupper(s)` | 字符串 `s` 转大写
|
||||
`getline` | 将 `$0` 设置为当前输入文件中的下一个输入记录
|
||||
|
||||
|
||||
### 用户定义函数
|
||||
|
||||
```shell
|
||||
@ -424,7 +423,6 @@ awk 'BEGIN {
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
### 带拆分的数组
|
||||
|
||||
```shell
|
||||
@ -536,7 +534,6 @@ awk -F: '{
|
||||
}' /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
Awk 循环
|
||||
----------
|
||||
|
||||
@ -744,6 +741,7 @@ daemon /sbin
|
||||
-------------
|
||||
|
||||
### 正则表达式元字符
|
||||
|
||||
- `\`
|
||||
- `^`
|
||||
- `$`
|
||||
@ -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)_
|
||||
|
Reference in New Issue
Block a user