-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jacky
committed
Jan 1, 2025
1 parent
9bf9241
commit aae041a
Showing
7 changed files
with
124 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
参考文章 https://tech.meituan.com/2016/11/04/nio.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,58 @@ | ||
#Linux | ||
## find | ||
find 命令,在指定路径下按照文件名、文件大小、文件类型等查找文件。 | ||
``` | ||
find [搜索路径] [搜索条件] [操作] | ||
``` | ||
|
||
### 按照文件名称搜索 | ||
比如在 / 路径下查找 mysql 开头的文件,-name 基于 shell 通配符进行匹配,如果使用 -iname 则忽略大小写: | ||
``` | ||
# find / -name "mysql*" | ||
/root/mysql-8.4.3-linux-glibc2.28-x86_64.tar.xz | ||
/srv/grafana/public/app/plugins/datasource/mysql | ||
``` | ||
### 按照文件类型搜索 | ||
可以按照文件类型查找,-type f 表示普通文件,-type d 表示目录,-type l 表示符号链接: | ||
``` | ||
find /usr/local -type f -name "*.txt" | ||
``` | ||
|
||
### 按照文件大小搜索 | ||
可以按照文件大小查找,-size +10M 表示大于 10M,-size -10M 表示小于 10M。c(字节)、k、M、G。注意,等于指定的大小的文件不会被列出来;可以使用 -szie +10M -size -100M 查询大于 10MB 小于 100MB 的文件。 | ||
``` | ||
find ./ -size +10M -size -100M -name "*.gz" | ||
``` | ||
|
||
### 按照文件的更新时间搜索 | ||
按照修改时间查找,-mtime -7 表示最近 7 天修改,-mtime +30 表示超过 30 天。 | ||
|
||
### 查找文件之后指定命令 | ||
查找文件后执行删除操作 | ||
``` | ||
find /root/ -name "*.tar.gz" -exec rm {} \; | ||
``` | ||
|
||
查找文件后移动到另一个目录: | ||
``` | ||
find /root/ -name "*.tar.gz" -exec mv {} /backup/dir \; | ||
``` | ||
|
||
## which | ||
which 查找可执行命令的路径,基于 PATH 环境变量进行搜寻。 | ||
```shell | ||
# which ls | ||
/usr/bin/ls | ||
``` | ||
|
||
|
||
## grep | ||
grep 命令能够结合正则表达式快速过滤文本的内容 | ||
``` | ||
grep [选项] "搜索模式" [文件] | ||
``` | ||
|
||
-i 忽略大小写 | ||
-v 反向匹配 | ||
-n 显示匹配的行号 | ||
-c 统计匹配的行数 | ||
-o 仅输出匹配的部分,默认输出整行 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters