From 0f5cf0331b9cd56f0d4bd71560a46fa65d5657ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=A9=E4=B8=9C?= <3187628460@qq.com> Date: Tue, 28 May 2024 08:34:27 +0800 Subject: [PATCH] hw --- ...50\345\222\214\345\244\215\345\210\266.md" | 10 +- ...57\345\276\204\344\275\234\344\270\232.md" | 284 ++++++++++++++++++ 2 files changed, 289 insertions(+), 5 deletions(-) create mode 100644 "\351\273\204\346\265\251\344\270\234/20240527 \350\267\257\345\276\204\344\275\234\344\270\232.md" diff --git "a/\351\273\204\346\265\251\344\270\234/20240524 \347\247\273\345\212\250\345\222\214\345\244\215\345\210\266.md" "b/\351\273\204\346\265\251\344\270\234/20240524 \347\247\273\345\212\250\345\222\214\345\244\215\345\210\266.md" index 7174f13..fef2ce7 100644 --- "a/\351\273\204\346\265\251\344\270\234/20240524 \347\247\273\345\212\250\345\222\214\345\244\215\345\210\266.md" +++ "b/\351\273\204\346\265\251\344\270\234/20240524 \347\247\273\345\212\250\345\222\214\345\244\215\345\210\266.md" @@ -52,20 +52,20 @@ ```shell mkdir backup - cp file2.txt /backup + cp file2.txt ./backup ``` 10. 将家目录/docs中的所有文件和子目录移动到家目录/archive中。 ```shell mkdir archive - mv -r ./docs /archive + mv -r ./docs ./archive ``` 11. 复制家目录/photos及其所有内容到家目录/backup中。 ```shell - cp -r ./photos /backup + cp -r ./photos ./backup ``` 12. 将文件家目录/docs/report.doc移动到家目录/papers中,并将其重命名为final_report.doc。 @@ -108,13 +108,13 @@ 18. 将家目录/docs中的所有文件移动到家目录/archive中,并且在移动时显示详细的移动信息。 ```shell - mv -rvf /docs/* /archive + mv -rvf ./docs/* ./archive ``` 19. 复制家目录/docs中的所有子目录及其内容到家目录/backup中。 ```shell - cp -r /docs /backup + cp -r ./docs ./backup ``` 20. 将家目录/docs中的所有文件和子目录移动到家目录/backup中,但排除文件名以"temp_"开头的文件。 diff --git "a/\351\273\204\346\265\251\344\270\234/20240527 \350\267\257\345\276\204\344\275\234\344\270\232.md" "b/\351\273\204\346\265\251\344\270\234/20240527 \350\267\257\345\276\204\344\275\234\344\270\232.md" new file mode 100644 index 0000000..160322c --- /dev/null +++ "b/\351\273\204\346\265\251\344\270\234/20240527 \350\267\257\345\276\204\344\275\234\344\270\232.md" @@ -0,0 +1,284 @@ +# 1相对路径 + +相关和目录可自行创建后再操作 + +1. 在家目录下建立文件exam.c,将文件exam.c拷贝到/tmp这个目录下,并改名为 shiyan.c + + ```shell + mkdir exam.c && cp exam.c ../../tmp + ``` + +2. 在任何目录下回到用户主目录? + + ```shell + cd ~ + ``` + +3. 用长格式列出/tmp/test目录下所有的文件包括隐藏文件? + + ```shell + ls ../../tmp/test -al + ``` + +4. /tmp/test2目录下,创建5个文件分别是 1.txt 2.txt 3.txt 4.txt 5.txt,压缩这5个文件,压缩包的名字是hailiang.tar + + ```shell + sudo touch ../../tmp/test2/1.txt ../../tmp/test2/2.txt ../../tmp/test2/3.txt ../../tmp/test2/4.txt ../../tmp/test2/5.txt && tar -czf ../../tmp/hailiang.tar ../../tmp/test2 + ``` + +5. 当前目录,建立文件 file1.txt 并更名为 file2.txt? + + ```shell + touch file1.txt && mv file1.txt file2.txt + ``` + +6. 当前目录,用vim建立文件bbbb.txt 并将用户名的加入其中保存退出? + + ```shell + vim bbbb.txt + ``` + +7. 将家目录中扩展名为txt、doc和bak的文件全部复制到/tmp/test目录中? + + ```shell + sudo cp -r *.txt *.doc *.bak ../../tmp/test + ``` + +8. 将文件file1.txt从当前目录移动到家目录的/docs中。 + + ```shell + mv file1.txt ./docs + ``` + +9. 复制文件file2.txt从当前目录到家目录/backup中。 + + ```shell + mkdir backup + cp file2.txt ./backup + ``` + +10. 将家目录/docs中的所有文件和子目录移动到家目录/archive中。 + + ```shell + mkdir archive + mv -r ./docs ./archive + ``` + +11. 复制家目录/photos及其所有内容到家目录/backup中。 + + ```shell + cp -r ./photos ./backup + ``` + +12. 将文件家目录/docs/report.doc移动到家目录/papers中,并将其重命名为final_report.doc。 + + ```shell + mv ./docs/report.doc ./papers/final_report.doc + ``` + +13. 在家目录/docs中创建一个名为notes.txt的空文件,并将其复制到目录家目录/backup中。 + + ```shell + touch ./docs/notes.txt && cp ./docs/notes.txt /backup + ``` + +14. 复制家目录/images中所有以.jpg结尾的文件到家目录/photos中。 + + ```shell + cp ./images/*.jpg ./photos + ``` + +15. 将文件家目录/docs/file1.txt和家目录/docs/file2.txt复制到家目录/backup中。 + + ```shell + cp ./docs/file1.txt ./docs/file2.txt ./backup + ``` + +16. 将家目录/docs中的所有.txt文件复制到家目录/text_files中。 + + ```shell + mkdir test_files + cp -r ./docs/*.txt ./text_files + ``` + +17. 将家目录/docs中的所有文件移动到家目录/temp中,并且如果文件已存在,则覆盖它们。 + + ```shell + mv -rf ./docs/* ../../temp + ``` + +18. 将家目录/docs中的所有文件移动到家目录/archive中,并且在移动时显示详细的移动信息。 + + ```shell + mv -rvf ./docs/* ./archive + ``` + +19. 复制家目录/docs中的所有子目录及其内容到家目录/backup中。 + + ```shell + cp -r ./docs ./backup + ``` + +20. 将家目录/docs中的所有文件和子目录移动到家目录/backup中,但排除文件名以"temp_"开头的文件。 + + ```shell + cp -r ./docs ./backup && rm -rf ./backup/docs/temp_* + ``` + +21. 将目录/docs/report.txt移动到家目录/archive中,但如果目标目录中已存在同名文件,则不直接覆盖,先备份同名文件为report.txt_bak。 + + ```shell + mv --backup=report.txt_bak ./docs/report.txt /archive -n + ``` + +22. 将家目录/docs中所有以.pdf结尾的文件复制到家目录/pdf_files中,并且如果目标目录中已存在同名文件,则忽略它们。 + + ```shell + mkdir pdf_files + cp -rn ./docs/*.pdf ./pdf_files + ``` + + + +# 2绝对路径 + +相关和目录可自行创建后再操作 + +1. 在家目录下建立文件exam.c,将文件exam.c拷贝到/tmp这个目录下,并改名为 shiyan.c + + ```shell + mkdir exam.c && cp exam.c /tmp + ``` + +2. 在任何目录下回到用户主目录? + + ```shell + cd /home/aim + ``` + +3. 用长格式列出/tmp/test目录下所有的文件包括隐藏文件? + + ```shell + ls /tmp/test -al + ``` + +4. /tmp/test2目录下,创建5个文件分别是 1.txt 2.txt 3.txt 4.txt 5.txt,压缩这5个文件,压缩包的名字是hailiang.tar + + ```shell + sudo touch /tmp/test2/1.txt /tmp/test2/2.txt tmp/test2/3.txt /tmp/test2/4.txt /tmp/test2/5.txt && tar -czf /tmp/hailiang.tar /tmp/test2 + ``` + +5. 当前目录,建立文件 file1.txt 并更名为 file2.txt? + + ```shell + touch /home/aim/file1.txt && mv /home/aim/file1.txt /home/aim/file2.txt + ``` + +6. 当前目录,用vim建立文件bbbb.txt 并将用户名的加入其中保存退出? + + ```shell + vim /home/aim/bbbb.txt + ``` + +7. 将家目录中扩展名为txt、doc和bak的文件全部复制到/tmp/test目录中? + + ```shell + sudo cp -r /home/aim/*.txt /home/aim/*.doc /home/aim/*.bak /tmp/test + ``` + +8. 将文件file1.txt从当前目录移动到家目录的/docs中。 + + ```shell + mv /home/aim/file1.txt /home/aim/docs + ``` + +9. 复制文件file2.txt从当前目录到家目录/backup中。 + + ```shell + mkdir backup + cp /home/aim/file2.txt /home/aim/backup + ``` + +10. 将家目录/docs中的所有文件和子目录移动到家目录/archive中。 + + ```shell + mkdir archive + mv -r /home/aim/docs /home/aim/archive + ``` + +11. 复制家目录/photos及其所有内容到家目录/backup中。 + + ```shell + cp -r /home/aim/photos /home/aim/backup + ``` + +12. 将文件家目录/docs/report.doc移动到家目录/papers中,并将其重命名为final_report.doc。 + + ```shell + mv /home/aim/docs/report.doc /home/aim/papers/final_report.doc + ``` + +13. 在家目录/docs中创建一个名为notes.txt的空文件,并将其复制到目录家目录/backup中。 + + ```shell + touch /home/aim/docs/notes.txt && cp /home/aim/docs/notes.txt /backup + ``` + +14. 复制家目录/images中所有以.jpg结尾的文件到家目录/photos中。 + + ```shell + cp /home/aim/images/*.jpg /home/aim/photos + ``` + +15. 将文件家目录/docs/file1.txt和家目录/docs/file2.txt复制到家目录/backup中。 + + ```shell + cp /home/aim/docs/file1.txt /home/aim/docs/file2.txt /home/aim/backup + ``` + +16. 将家目录/docs中的所有.txt文件复制到家目录/text_files中。 + + ```shell + mkdir test_files + cp -r /home/aim/docs/*.txt /home/aim/text_files + ``` + +17. 将家目录/docs中的所有文件移动到家目录/temp中,并且如果文件已存在,则覆盖它们。 + + ```shell + mv -rf /home/aim/docs/* /temp + ``` + +18. 将家目录/docs中的所有文件移动到家目录/archive中,并且在移动时显示详细的移动信息。 + + ```shell + mv -rvf /home/aim/docs/* /home/aim/archive + ``` + +19. 复制家目录/docs中的所有子目录及其内容到家目录/backup中。 + + ```shell + cp -r /home/aim/docs /home/aim/backup + ``` + +20. 将家目录/docs中的所有文件和子目录移动到家目录/backup中,但排除文件名以"temp_"开头的文件。 + + ```shell + cp -r /home/aim/docs /home/aim/backup/!{trmp_*} + ``` + +21. 将目录/docs/report.txt移动到家目录/archive中,但如果目标目录中已存在同名文件,则不直接覆盖,先备份同名文件为report.txt_bak。 + + ```shell + mv -bS _bak /home/aim/docs/report.txt /home/aim/archive -n + ``` + +22. 将家目录/docs中所有以.pdf结尾的文件复制到家目录/pdf_files中,并且如果目标目录中已存在同名文件,则忽略它们。 + + ```shell + mkdir pdf_files + cp -rn /home/aim/docs/*.pdf /home/aim/pdf_files + ``` + + + -- Gitee