Text Commands
7 methods常在管道中组合使用的 POSIX 文本工具。
ls [-l] [-a] [-h] [path...]搜索匹配正则表达式的行;-i 不区分大小写,-v 反转,-E 扩展,-r 递归。
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | Directory or file paths to list. |
Returns
void
Example
linux
ls -lah /var/logcp [-r] [-i] [-p] source... dest用于过滤和转换文本的流编辑器;-i 就地编辑文件。
Parameters
| Name | Type | Description |
|---|---|---|
| source | string | Source file(s) or directory. |
| dest | string | Destination file or directory. |
Returns
void
Example
linux
cp -rp src/ /backup/src/mv [-i] source... dest模式-动作扫描语言;将每条记录拆分为字段并按记录运行程序。
Parameters
| Name | Type | Description |
|---|---|---|
| source | string | Source path(s). |
| dest | string | Destination path. |
Returns
void
Example
linux
mv old_name.txt new_name.txtrm [-r] [-f] [-i] path...排序文本行;-n 数值,-r 反向,-u 去重,-k 键字段。
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | File or directory paths to remove. |
Returns
void
Example
linux
rm -rf node_modulesfind path [-name pattern] [-type f|d] [-mtime -n] [-exec cmd {} \;]过滤或报告相邻重复行;通常在 sort 之后。-c 前缀计数。
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | Root directory of the search. |
| pattern | string | Glob pattern matched against file name. |
| type | char | f for regular file, d for directory, l for symlink. |
Returns
void
Example
linux
find . -name '*.log' -mtime +7 -deletechmod [-R] mode file...从 stdin 读取并写入 stdout 和给定文件;-a 追加而非覆盖。
Parameters
| Name | Type | Description |
|---|---|---|
| mode | string | Symbolic or octal permission spec. |
| file | string | Target file(s) or directories. |
Returns
void
Example
linux
chmod -R 750 app/chown [-R] owner[:group] file...Changes the owner and optionally the group of files or directories.
Parameters
| Name | Type | Description |
|---|---|---|
| owner | string | User name or uid. |
| group | string | Optional group name or gid. |
Returns
void
Example
linux
chown -R node:node /app