mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
quest: "remove" finish, a bug in last stage
This commit is contained in:
1 parent
28cd2a7ac7
commit
1ab3e577c1
9 files changed
+255
-1
No files matched your search
@@ -0,0 +1,3 @@
|
||||
FROM linuxodyssey/quest-base
|
||||
|
||||
COPY --chown=${USERNAME} home ${HOME}
|
||||
+248
-1
@@ -1,7 +1,254 @@
|
||||
title: 刪除檔案與資料夾
|
||||
instruction: |
|
||||
刪除檔案
|
||||
在這個關卡中,你會學到如何用 `rm` 與 `rmdir` 指令刪除檔案與資料夾。
|
||||
現在資料夾裡有一些檔案與資料夾,請你使用 `ls` 跟 `cat` 來查看它們的內容。
|
||||
準備好就輸入 `echo start` 開始吧!
|
||||
|
||||
requirements:
|
||||
- copy
|
||||
- move
|
||||
|
||||
stages:
|
||||
- id: start
|
||||
task: 輸入 `echo start` 來開始
|
||||
condition:
|
||||
command:
|
||||
- ^echo
|
||||
output:
|
||||
- start
|
||||
responses:
|
||||
- content:
|
||||
- 今天我們要學習如何刪除檔案與資料夾。
|
||||
- '首先要來學習 `rm` 指令。`rm` 指令可以用來刪除檔案。使用方式是 `rm [檔案名稱]`。'
|
||||
- '現在請你使用 `rm` 指令刪除 `hello.txt`。'
|
||||
hints:
|
||||
- 使用 `rm hello.txt` 來刪除 `hello.txt`。
|
||||
|
||||
- id: rm-hello
|
||||
requirements:
|
||||
- start
|
||||
task: 使用 `rm` 刪除 `hello.txt`
|
||||
condition:
|
||||
command:
|
||||
- ^rm
|
||||
files:
|
||||
- path: hello.txt
|
||||
exists: false
|
||||
responses:
|
||||
- content:
|
||||
- '很好!現在請你使用 `ls` 指令來查看資料夾內容。'
|
||||
|
||||
- id: ls-no-hello
|
||||
requirements:
|
||||
- rm-hello
|
||||
task: 使用 `ls` 查看資料夾內容
|
||||
condition:
|
||||
command:
|
||||
- ^ls
|
||||
files:
|
||||
- path: hello.txt
|
||||
exists: false
|
||||
responses:
|
||||
- content:
|
||||
- '你會發現 `hello.txt` 已經不見了。'
|
||||
- '`rm` 也可以同時刪除多個檔案,只要把檔案名稱用空白隔開就可以了,也就是 `rm [檔案1] [檔案2] ...`。'
|
||||
- 現在請你使用 `rm` 刪除 `world.txt` 與 `wow.txt`。
|
||||
hints:
|
||||
- 使用 `rm world.txt wow.txt` 來刪除 `world.txt` 與 `wow.txt`。
|
||||
- 檔案名稱之間要用空白隔開。
|
||||
- 名稱的順序不重要。
|
||||
|
||||
- id: rm-world-wow
|
||||
requirements:
|
||||
- ls-no-hello
|
||||
task: 使用 `rm` 刪除 `world.txt` 與 `wow.txt`
|
||||
condition:
|
||||
command:
|
||||
- ^rm
|
||||
files:
|
||||
- path: world.txt
|
||||
exists: false
|
||||
- path: wow.txt
|
||||
exists: false
|
||||
responses:
|
||||
- content:
|
||||
- '很好!我們一樣用 `ls` 指令確認一下資料夾內容。'
|
||||
hints:
|
||||
- 使用 `ls` 來查看資料夾內容。
|
||||
|
||||
- id: ls-no-world-wow
|
||||
requirements:
|
||||
- rm-world-wow
|
||||
task: 使用 `ls` 查看資料夾內容
|
||||
condition:
|
||||
command:
|
||||
- ^ls$
|
||||
responses:
|
||||
- content:
|
||||
- '你會發現 `world.txt` 與 `wow.txt` 已經不見了。'
|
||||
- '現在我們來學習 `rmdir` 指令。`rmdir` 指令可以用來刪除資料夾。使用方式是 `rmdir [資料夾名稱]`。'
|
||||
- '現在請你使用 `rmdir` 指令刪除 `empty` 資料夾。'
|
||||
hints:
|
||||
- 使用 `rmdir empty` 來刪除 `empty` 資料夾。
|
||||
|
||||
- id: rm-empty
|
||||
requirements:
|
||||
- ls-no-world-wow
|
||||
task: 使用 `rmdir` 刪除 `empty` 資料夾
|
||||
condition:
|
||||
command:
|
||||
- ^rmdir
|
||||
files:
|
||||
- path: empty
|
||||
exists: false
|
||||
responses:
|
||||
- content:
|
||||
- '很好!現在請你使用 `ls` 指令來查看資料夾內容。'
|
||||
|
||||
- id: ls-no-empty
|
||||
requirements:
|
||||
- rm-empty
|
||||
task: 使用 `ls` 查看資料夾內容
|
||||
condition:
|
||||
command:
|
||||
- ^ls$
|
||||
responses:
|
||||
- content:
|
||||
- '你會發現 `empty` 資料夾已經不見了。'
|
||||
- '現在請你試試看 `rmdir` 指令刪除 `notes` 資料夾。'
|
||||
hints:
|
||||
- 使用 `rmdir notes` 來刪除 `notes` 資料夾。
|
||||
|
||||
- id: rm-notes-failed
|
||||
requirements:
|
||||
- ls-no-empty
|
||||
task: 使用 `rmdir` 刪除 `notes` 資料夾
|
||||
condition:
|
||||
command:
|
||||
- ^rmdir notes$
|
||||
files:
|
||||
- path: notes
|
||||
type: folder
|
||||
exists: true
|
||||
responses:
|
||||
- content:
|
||||
- 指令執行失敗了!
|
||||
- '你會發現 `notes` 資料夾還在。'
|
||||
- '這是因為 `rmdir` 指令只能刪除空的資料夾。'
|
||||
- 我們先來將 `notes` 資料夾的檔案刪除再來試一次。
|
||||
- '現在請你使用 `rm` 指令刪除 `notes` 資料夾內的檔案。'
|
||||
hints:
|
||||
- 使用 `rm notes/[檔案名稱]` 來刪除 `notes` 資料夾內的檔案。
|
||||
- 你可能需要使用 `ls notes` 來查看 `notes` 資料夾內有哪些檔案。
|
||||
|
||||
- id: rm-notes-content
|
||||
requirements:
|
||||
- rm-notes-failed
|
||||
task: 使用 `rm` 刪除 `notes` 資料夾內的檔案
|
||||
condition:
|
||||
command:
|
||||
- ^rm
|
||||
files:
|
||||
- path: notes
|
||||
type: folder
|
||||
exists: true
|
||||
- path: notes/note.txt
|
||||
exists: false
|
||||
responses:
|
||||
- content:
|
||||
- '很好!現在我們再使用 `rmdir` 指令刪除 `notes` 資料夾。'
|
||||
hints:
|
||||
- 使用 `rmdir notes` 來刪除 `notes` 資料夾。
|
||||
exceptions:
|
||||
- condition:
|
||||
command:
|
||||
- ^rm notes/\[.*\]
|
||||
responses:
|
||||
- content:
|
||||
- '你好像理解錯了。'
|
||||
- 這邊中括號包起來 `[檔案名稱]` 是參數的意思,需要你自己填入檔案的名稱。
|
||||
- 實際打指令的時候,不要打中括號 `[]` 喔!
|
||||
- '例如,如果要刪除 `notes` 資料夾內的 `note.txt` 檔案,指令應該要是 `rm notes/note.txt`。'
|
||||
- 請先用 `ls notes` 確認 `notes` 資料夾內有哪些檔案,再來試試看吧!
|
||||
- condition:
|
||||
command:
|
||||
- ^rm
|
||||
error:
|
||||
- 'No such file or directory'
|
||||
responses:
|
||||
- content:
|
||||
- 這個錯誤的意思是找不到檔案
|
||||
- '請先用 `ls notes` 確認 `notes` 資料夾內有哪些檔案,再來試試看吧!'
|
||||
|
||||
- condition:
|
||||
command:
|
||||
- ^ls notes$
|
||||
responses:
|
||||
- content:
|
||||
- '`notes` 資料夾中有著 `note.txt` 檔案。'
|
||||
- 那我們就使用 `rm notes/note.txt` 來刪除 `note.txt` 檔案吧!
|
||||
|
||||
- id: rm-notes
|
||||
requirements:
|
||||
- rm-notes-content
|
||||
task: 使用 `rmdir` 刪除 `notes` 資料夾
|
||||
condition:
|
||||
command:
|
||||
- ^rmdir
|
||||
files:
|
||||
- path: notes
|
||||
exists: false
|
||||
responses:
|
||||
- content:
|
||||
- '很好!`notes` 資料夾已經被刪除了。'
|
||||
- 接下來我們來刪除 `trash` 資料夾。
|
||||
- 先使用 `ls` 指令查看一下 `trash` 資料夾內容。
|
||||
hints:
|
||||
- 使用 `ls trash` 來查看 `trash` 中的檔案。
|
||||
|
||||
- id: ls-trash
|
||||
requirements:
|
||||
- rm-notes
|
||||
task: 使用 `ls` 查看 `trash` 資料夾內容
|
||||
condition:
|
||||
command:
|
||||
- ^ls
|
||||
output:
|
||||
- garbage.txt
|
||||
responses:
|
||||
- content:
|
||||
- 天啊!`trash` 資料夾裡有好多檔案,甚至還有其他的資料夾!
|
||||
- 如果今天資料夾中有很多檔案與資料夾,我們不想一個一個刪除,該怎麼辦呢?
|
||||
- 跟 `cp` 的時候一樣,這時候我們可以加上 `-r` 的選項來刪除資料夾與它的所有檔案。
|
||||
- '`-r` 的意思是遞迴(recursive),也就是會把資料夾中的所有檔案都刪除。'
|
||||
- 我們來試試看吧!
|
||||
hints:
|
||||
- 使用 `rm -r trash` 來刪除 `trash` 資料夾。
|
||||
|
||||
- id: rm-trash
|
||||
requirements:
|
||||
- ls-trash
|
||||
task: 使用 `rm -r` 刪除 `trash` 資料夾
|
||||
condition:
|
||||
command:
|
||||
- ^rm -r
|
||||
files:
|
||||
- path: trash
|
||||
exists: false
|
||||
responses:
|
||||
- content:
|
||||
- '很好!現在請你使用 `ls` 指令查看資料夾內容。'
|
||||
hints:
|
||||
- 使用 `ls` 來查看資料夾內容。
|
||||
|
||||
- id: END
|
||||
requirements:
|
||||
- rm-trash
|
||||
task: 使用 `ls` 查看資料夾內容
|
||||
condition:
|
||||
command:
|
||||
- ^ls$
|
||||
responses:
|
||||
- content:
|
||||
- '`trash` 資料夾已經不見了。'
|
||||
- 恭喜你!你已經學會如何刪除檔案與資料夾了!
|
||||
@@ -0,0 +1 @@
|
||||
Hello
|
||||
@@ -0,0 +1 @@
|
||||
Note
|
||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1 @@
|
||||
World
|
||||
@@ -0,0 +1 @@
|
||||
Wow
|
||||
Reference in new issue
Block a user