Merge branch 'quest-file' into quest

This commit is contained in:
Chen, Tai-Lin committed 2023-11-22 19:28:34 +08:00
commit 956af624c6
69 files changed
+1232 -260

No files matched your search

+18 -4
View File
@@ -1,6 +1,8 @@
title: 複製檔案
instruction: |
在這個關卡中,你將學習如何複製檔案。
在這個關卡中,你會學習到:
1. 如何用 `cp` 指令複製檔案。
準備好就輸入 `echo start` 來開始吧!
requirements:
- create
@@ -170,11 +172,14 @@ stages:
- 接下來我們要來學習如何複製資料夾。
- 現在目錄下有一個 `notes` 資料夾,裡面有一個 `note.txt` 的檔案。
- 我們要能整個資料夾包含裡面的檔案一起複製到 `notes2`。
- 跟複製單一檔案不一樣的是,複製資料夾時,我們要加上 `-r` 的參數,recursive,代表遞迴地將資料夾中的所有檔案都複製出來。
- 跟複製單一檔案不一樣的是,複製資料夾時,我們要加上 `-r` 的選項(recursive)代表將資料夾中的所有檔案都一起複製。
- 在使用指令時,如果想要調整指令的行為,可以在指令後面加上選項。
- 選項的格式通常是 `-` 加上一個字母,例如 `-r`。
- 選項擺放的位置沒有特別的限制,通常會跟在指令的後面,置於檔案名稱的前面。
- 請你使用 `cp -r notes notes2` 來複製 `notes` 資料夾到 `notes2`。
hints:
- 使用 `cp -r notes notes2` 來複製 `notes` 資料夾到 `notes2`
- 記得要加上 `-r` 的參數來複製所有檔案
- 記得要加上 `-r` 的選項來複製所有檔案
- id: cp-notes
requirements:
@@ -182,7 +187,7 @@ stages:
task: 複製 `notes` 資料夾到 `notes2`
condition:
command:
- ^cp -r notes notes2$
- ^cp
files:
- path: notes2
type: directory
@@ -195,6 +200,15 @@ stages:
- 我們打開來確認一下 `notes2` 資料夾的內容吧!
hints:
- 使用 `ls notes2` 來查看 `notes2` 資料夾的內容
exceptions:
- condition:
error:
- 'cp: omitting directory'
responses:
- type: narrative
content:
- 你忘記加上 `-r` 的參數了嗎?
- 請輸入 `cp -r notes notes2` 來複製 `notes` 資料夾到 `notes2`
- id: ls-notes2
requirements:
+1 -1
View File
@@ -1 +1 @@
Hello
Hello
+1 -1
View File
@@ -1 +1 @@
Note
Note
+1 -1
View File
@@ -1 +1 @@
World
World
+20 -2
View File
@@ -1,6 +1,9 @@
title: 建立檔案與資料夾
instruction: |
在這個關卡中,你將學習如何建立檔案與資料夾。
在這個關卡中,你會學習到:
1. 如何使用 `touch` 建立檔案
2. 如何使用 `mkdir` 建立資料夾
準備好就輸入 `echo start` 開始吧!
stages:
- id: start
@@ -47,7 +50,22 @@ stages:
- type: narrative
content:
- 你應該可以看到終端機上顯示了 `hello.txt` 這個檔案。
- 我們再來試試建立其他的檔案吧!
- 我們來看看 `hello.txt` 檔案的內容吧!
- 我們可以使用之前學過的 `cat` 指令來查看檔案內容。
hints:
- 輸入 `cat hello.txt` 來查看 `hello.txt` 檔案的內容
- id: cat
condition:
command:
- ^cat hello.txt$
responses:
- type: narrative
content:
- 咦?竟然什麼都沒有!
- 沒錯,使用 `touch` 指令建立的檔案是空的。
- 我們在未來會學習如何編輯檔案的內容。
- 再來試試建立其他的檔案吧!
- 請你試著在終端機上建立另一個檔案,檔名為 `world.txt`。
hints:
- 輸入 `touch world.txt` 來建立一個檔案
+3
View File
@@ -0,0 +1,3 @@
FROM linuxodyssey/quest-base
COPY --chown=${USERNAME} home ${HOME}
+214 -1
View File
@@ -1,6 +1,219 @@
title: 移動檔案
instruction: |
移動檔案
在這個關卡中,你會學到:
1. 如何用 `mv` 移動檔案與資料夾
準備好就輸入 `echo start` 來開始吧!
requirements:
- create
stages:
- id: start
task: 輸入 `echo start` 來開始
condition:
command:
- ^echo start$
responses:
- type: narrative
content:
- 今天我們要學習如何移動檔案與資料夾。
- 現在資料夾裡有一個 `hello.txt` 跟一個 `world.txt`,以及一個 `notes` 資料夾。
- 請先用 `ls` 與 `cat` 來查看它們的內容。
- 看完之後,使用 `echo continue` 來繼續吧!
hints:
- 用 `ls`、`ls notes` 來查看資料夾內的檔案
- 用 `cat hello.txt` 以及 `cat world.txt` 來查看檔案內容
- 完成後輸入 `echo continue` 來繼續
- id: continue
requirements:
- start
task: 查看檔案內容,完成後輸入 `echo continue` 來繼續
condition:
command:
- ^echo continue$
responses:
- type: narrative
content:
- 現在我們要來學習如何移動檔案與資料夾。
- '`mv` 指令是移動 move 的縮寫,可以用來移動檔案與資料夾。'
- 使用方式為 `mv [來源] [目的地]`。
- 我們先來將 `hello.txt` 移動到 `notes` 資料夾中吧!
hints:
- 使用 `mv hello.txt notes` 來將 `hello.txt` 移動到 `notes` 資料夾中
- id: mv-hello
requirements:
- continue
task: 將 `hello.txt` 移動到 `notes` 資料夾中
condition:
command:
- ^mv hello.txt notes$
files:
- path: notes/hello.txt
type: file
- path: hello.txt
exists: false
responses:
- type: narrative
content:
- 你做得很好!
- 我們用 `ls` 跟 `ls notes` 來查看一下資料夾內的檔案吧!
hints:
- 使用 `ls`、`ls notes` 來查看資料夾內的檔案
- id: ls-no-hello
requirements:
- mv-hello
task: 檢查 `hello.txt` 是否還在資料夾中
condition:
pwd:
- ^/home/commander$
command:
- ^ls$
responses:
- type: narrative
content:
- '`hello.txt` 已經不在資料夾中了!'
- id: ls-notes-hello
requirements:
- mv-hello
task: 檢查 `hello.txt` 是否在 `notes` 資料夾中
condition:
pwd:
- ^/home/commander$
command:
- ^ls notes$
output:
- hello.txt
responses:
- type: narrative
content:
- '`hello.txt` 出現在 `notes` 資料夾中了!'
- id: continue-mv
requirements:
- ls-no-hello
- ls-notes-hello
task: 輸入 `echo continue` 來繼續
condition:
command:
- ^echo continue$
responses:
- type: narrative
content:
- '`mv` 指令也可以用來更改檔案名稱。'
- '只要將目的地改成新的檔案名稱就可以了。'
- 現在我們要將 `world.txt` 更名為 `wow.txt`。
hints:
- 使用 `mv world.txt wow.txt` 來將 `world.txt` 更名為 `wow.txt`
- id: mv-world
requirements:
- continue-mv
task: 將 `world.txt` 更名為 `wow.txt`
condition:
command:
- ^mv
files:
- path: wow.txt
type: file
- path: world.txt
exists: false
responses:
- type: narrative
content:
- 你做得很好!
- 我們用 `ls` 來確認一下資料夾內的檔案吧!
hints:
- 使用 `ls` 來查看資料夾內的檔案
- id: ls-wow
requirements:
- mv-world
task: 檢查 `wow.txt` 是否存在
condition:
pwd:
- ^/home/commander$
command:
- ^ls$
output:
- wow.txt
responses:
- type: narrative
content:
- '`world.txt` 現在已經變成 `wow.txt` 了。'
- 接下來我們來學習如何移動資料夾吧!
- 移動資料夾非常簡單,方法跟移動檔案一樣。
- '`mv` 指令會自動將資料夾內的所有檔案一起移動'
- 我們先來將 `notes` 資料夾改名叫作 `docs` 吧!
hints:
- 使用 `mv notes docs` 來將 `notes` 資料夾改名叫作 `docs`
- id: mv-notes
requirements:
- ls-wow
task: 將 `notes` 資料夾改名叫作 `docs`
condition:
command:
- ^mv
files:
- path: docs
type: directory
- path: notes
exists: false
responses:
- type: narrative
content:
- 你做得很好!
- 我們用 `ls` 來確認一下資料夾內的檔案吧!
hints:
- 使用 `ls` 來查看資料夾內的檔案
- id: ls-docs
requirements:
- mv-notes
task: 檢查 `docs` 資料夾是否存在
condition:
pwd:
- ^/home/commander$
command:
- ^ls$
output:
- docs
responses:
- type: narrative
content:
- '`notes` 資料夾已經變成 `docs` 了。'
- 那麼最後來考考你:
- 試著將 `docs/hello.txt` 移動到家目錄底下的 `hi.txt`。
- 如果你不知道怎麼做,可以輸入 `echo hint` 來取得提示。
- id: END
requirements:
- ls-docs
task: 將 `docs/hello.txt` 移動到家目錄底下的 `hi.txt`
condition:
command:
- ^mv
files:
- path: hi.txt
type: file
- path: docs/hello.txt
exists: false
responses:
- type: narrative
content:
- 你做得很好!
- 你已經學會如何移動檔案與資料夾了!
exceptions:
- condition:
command:
- ^echo hint$
responses:
- type: narrative
content:
- 你可以使用 `mv docs/hello.txt hi.txt` 來完成這個任務。
hints:
- 使用 `mv docs/hello.txt hi.txt` 來將 `docs/hello.txt` 移動到家目錄底下的 `hi.txt`
+1
View File
@@ -0,0 +1 @@
Hello
+1
View File
@@ -0,0 +1 @@
Note
+1
View File
@@ -0,0 +1 @@
World
+3
View File
@@ -0,0 +1,3 @@
FROM linuxodyssey/quest-base
COPY --chown=${USERNAME} home ${HOME}
+251 -1
View File
@@ -1,7 +1,257 @@
title: 刪除檔案與資料夾
instruction: |
刪除檔案
在這個關卡中,你會學到:
1. 用 `rm` 指令刪除檔案
2. 用 `rmdir` 與資料夾。
3. 用 `rm -r` 刪除資料夾與它的所有檔案。
現在資料夾裡有一些檔案與資料夾,請你使用 `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` 資料夾已經不見了。'
- 恭喜你!你已經學會如何刪除檔案與資料夾了!
+1
View File
@@ -0,0 +1 @@
Hello
+1
View File
@@ -0,0 +1 @@
Note
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
+1
View File
@@ -0,0 +1 @@
World
+1
View File
@@ -0,0 +1 @@
Wow