From b63c9bd7017c0c29f1c640448e096361f75bff4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=8B=87?= <2711273115@qq.com> Date: Wed, 29 May 2024 17:00:03 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈志勇 <2711273115@qq.com> --- ...63\347\232\204\347\273\203\344\271\240.md" | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 "19\351\231\210\345\277\227\345\213\207/0528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" diff --git "a/19\351\231\210\345\277\227\345\213\207/0528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" "b/19\351\231\210\345\277\227\345\213\207/0528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" new file mode 100644 index 0000000..ed23de0 --- /dev/null +++ "b/19\351\231\210\345\277\227\345\213\207/0528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" @@ -0,0 +1,89 @@ +### 操作题 + +1. **查找当前目录及其子目录中所有扩展名为 `.log` 的文件**: + + ```bash + find * -name "*.log" -type f + ``` + +2. **在 `/var/logs` 目录及其子目录中查找所有包含关键字 `error` 的文件,并显示匹配的行**: + + ```bash + sudo chown user:group 1.txt // 没有权限给用户这个文件的权限 + grep "error" /var/logs/* --color=auto -Hn + ``` + +3. **在 `/home/user/docs` 目录中查找文件名包含 `report` 的所有文件**: + ```bash + find ~/docs -name "*report*" -type f + ``` + +4. **查找 `/etc` 目录中最近7天内修改过的文件**: + ```bash + find /etc -mtime -7 -type f + ``` + +5. **显示 `/usr/bin` 目录中名为 `python` 的可执行文件的路径**: + + ```bash + 要先安装 + which python + /usr/bin/python + ``` + +6. **查找系统中名为 `ls` 的命令及其手册页位置**: + + ```bash + whereis ls + ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz + ``` + +7. **查找当前目录中包含关键字 `TODO` 的所有文件,并显示匹配的行和文件名**: + ```bash + grep -r "TODO" ./* -Hn + ``` + +8. **在 `/home/user/projects` 目录中查找所有包含关键字 `function` 的 `.js` 文件**: + ```bash + find ~/projects -name "*.js" -exec grep + "function" {} \; + ``` + +9. **查找并显示当前目录及其子目录中所有空文件**: + + ```bash + find ./ -empty + ``` + +10. **在 `/var/www` 目录中查找包含关键字 `database` 的所有文件,并只显示文件名**: + + ```bash + grep -rl "database" /var/www + ``` + +### 综合操作题 + +**综合操作题:** + +假设你在一个名为 `/home/user/workspace` 的目录中工作。你需要完成以下任务: + +1. 查找该目录中所有扩展名为 `.conf` 的文件。 +2. 在这些 `.conf` 文件中查找包含关键字 `server` 的行。 +3. 将包含关键字 `server` 的文件名和匹配的行保存到一个名为 `server_lines.txt` 的文件中。 + +**预期命令步骤:** + +1. 查找所有扩展名为 `.conf` 的文件: + ```bash + find ./ -name "*.conf" -type f + ``` + +2. 在这些 `.conf` 文件中查找包含关键字 `server` 的行: + ```bash + find ./ -name "*.conf" -type f -exec grep "server" {} -nH \; + ``` + +3. 将结果保存到 `server_lines.txt` 文件中: + ```bash + find ./ -name "*.conf" -type f -exec grep "server" {} -nH \; >> ./server_lines.txt + ``` \ No newline at end of file -- Gitee From 642a77fd102bd7139e644ad032433b2b3ae90057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=8B=87?= <2711273115@qq.com> Date: Wed, 29 May 2024 17:00:26 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=2019=E9=99=88?= =?UTF-8?q?=E5=BF=97=E5=8B=87/0528=20=E6=9F=A5=E8=AF=A2=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=9A=84=E7=BB=83=E4=B9=A0.md=20=E4=B8=BA=20?= =?UTF-8?q?19=E9=99=88=E5=BF=97=E5=8B=87/20240528=20=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E7=9B=B8=E5=85=B3=E7=9A=84=E7=BB=83=E4=B9=A0?= =?UTF-8?q?.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...47\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "19\351\231\210\345\277\227\345\213\207/0528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" => "19\351\231\210\345\277\227\345\213\207/20240528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" (100%) diff --git "a/19\351\231\210\345\277\227\345\213\207/0528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" "b/19\351\231\210\345\277\227\345\213\207/20240528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" similarity index 100% rename from "19\351\231\210\345\277\227\345\213\207/0528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" rename to "19\351\231\210\345\277\227\345\213\207/20240528 \346\237\245\350\257\242\345\221\275\344\273\244\347\233\270\345\205\263\347\232\204\347\273\203\344\271\240.md" -- Gitee