mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
* quest: remove ls-stages in create * feat: prevent throwing errors when failed to copy files * feat: log new command in dev mode * quest: copy * quest: mv * quest: rm * quest: execute. Add many exceptions * feat: pwd discovers parent folders
137 lines
4.2 KiB
YAML
137 lines
4.2 KiB
YAML
id: move
|
|
title: 移動檔案
|
|
image: base
|
|
instruction: |
|
|
在這個關卡中,你將會學到:
|
|
1. 如何使用 `mv` 移動檔案與資料夾
|
|
|
|
requirements:
|
|
- create
|
|
|
|
stages:
|
|
- id: start
|
|
name: 按下 `開始` 按鈕開始
|
|
condition:
|
|
command: echo start
|
|
response:
|
|
content: |
|
|
今天我們要學習如何移動檔案與資料夾。
|
|
現在資料夾裡有一個 `hello.txt` 跟一個 `world.txt`,以及一個 `notes` 資料夾。
|
|
請先用 `ls` 與 `cat` 來查看它們的內容。
|
|
看完之後,使用 `echo next` 來繼續吧!
|
|
hint: |
|
|
用 `ls`、`ls notes` 來查看資料夾內的檔案
|
|
用 `cat hello.txt` 以及 `cat world.txt` 來查看檔案內容
|
|
完成後輸入 `echo next` 來繼續
|
|
|
|
- id: next
|
|
requirements:
|
|
- start
|
|
name: 查看檔案內容,完成後輸入 `echo next` 來繼續
|
|
condition:
|
|
command: echo next
|
|
response:
|
|
content: |
|
|
現在我們要來學習如何移動檔案與資料夾。
|
|
`mv` 指令是移動 move 的縮寫,可以用來移動檔案與資料夾。
|
|
使用方式為 `mv [來源] [目的地]`。
|
|
我們先來將 `hello.txt` 移動到 `notes` 資料夾中吧!
|
|
hint: 使用 `mv hello.txt notes` 來將 `hello.txt` 移動到 `notes` 資料夾中
|
|
|
|
- id: mv-hello
|
|
requirements:
|
|
- next
|
|
name: 將 `hello.txt` 移動到 `notes` 資料夾中
|
|
condition:
|
|
command: mv hello.txt notes
|
|
files:
|
|
- path: /home/commander/notes/hello.txt
|
|
type: file
|
|
exists: true
|
|
- path: /home/commander/hello.txt
|
|
type: file
|
|
exists: false
|
|
response:
|
|
content: |
|
|
你做得很好!
|
|
`hello.txt` 已經移動到 `notes` 資料夾中了!
|
|
|
|
`mv` 指令不只可以移動檔案,還可以改檔案的名字哦!
|
|
只要把目標改成你想要的新名字就行了。
|
|
現在,我們要把 `world.txt` 改名成 `wow.txt`。
|
|
hint: 使用 `mv world.txt wow.txt` 來將 `world.txt` 更名為 `wow.txt`
|
|
|
|
- id: mv-world
|
|
requirements:
|
|
- mv-hello
|
|
name: 將 `world.txt` 更名為 `wow.txt`
|
|
condition:
|
|
command: mv world.txt wow.txt
|
|
files:
|
|
- path: /home/commander/wow.txt
|
|
type: file
|
|
exists: true
|
|
- path: /home/commander/world.txt
|
|
type: file
|
|
exists: false
|
|
response:
|
|
content: |
|
|
`world.txt` 現在已經變成 `wow.txt` 了。
|
|
|
|
接下來我們來學習如何移動資料夾吧!
|
|
移動資料夾跟移動檔案一樣。
|
|
`mv` 指令會自動將資料夾內的所有檔案一起移動
|
|
我們先來將 `notes` 資料夾改名叫作 `docs` 吧!
|
|
hint: 使用 `mv notes docs` 來將 `notes` 資料夾改名叫作 `docs`
|
|
|
|
- id: mv-notes
|
|
requirements:
|
|
- mv-world
|
|
name: 將 `notes` 資料夾改名叫作 `docs`
|
|
condition:
|
|
command: mv notes docs
|
|
files:
|
|
- path: /home/commander/docs
|
|
type: directory
|
|
exists: true
|
|
- path: /home/commander/notes
|
|
type: directory
|
|
exists: false
|
|
response:
|
|
content: |
|
|
`notes` 資料夾已經變成 `docs` 了。
|
|
那麼最後來考考你:
|
|
試著將 `docs/hello.txt` 移動到家目錄底下的 `hi.txt`。
|
|
hint: 使用 `mv docs/hello.txt hi.txt` 來將 `docs/hello.txt` 移動到家目錄底下的 `hi.txt`
|
|
|
|
- id: mv-docs-hello
|
|
requirements:
|
|
- mv-notes
|
|
name: 將 `docs/hello.txt` 移動到家目錄底下的 `hi.txt`
|
|
condition:
|
|
command: mv docs/hello.txt hi.txt
|
|
files:
|
|
- path: /home/commander/hi.txt
|
|
type: file
|
|
exists: true
|
|
- path: /home/commander/docs/hello.txt
|
|
type: file
|
|
exists: false
|
|
response:
|
|
content: |
|
|
你做得很好!
|
|
你已經學會如何移動檔案與資料夾了!
|
|
|
|
請輸入 `echo finish` 來完成這個關卡。
|
|
|
|
- id: END
|
|
requirements:
|
|
- mv-docs-hello
|
|
name: 完成關卡
|
|
condition:
|
|
command: echo finish
|
|
response:
|
|
content: |
|
|
你已經學會如何移動檔案與資料夾了!
|
|
恭喜你完成這個關卡!
|