Quest 101Loop-King
+280 XP
Automating with Loops
Launch Interactive Terminal for This Quest→No installation required • Runs fully in browser
Concept & Overview
Imagine having a folder of 100 log files, and you need to make a backup copy of every single one. Copying them individually would be exhausting. In Linux, we use for loops to repeat the same action across a whole list of items automatically!
- A for loop (like for file in *.txt; do ... done) iterates over every item that matches a pattern, processing them one after the other in a split second.
Mission Instructions
Let's automate backups. Create a script named
backup_logs.sh. Have it create a directory named backup (using mkdir -p backup), then use a for loop to copy all .log files in the current folder into backup. Make it executable and run it.Command Syntax Reference
| Command / Syntax | Description |
|---|---|
for x in pattern; do ... | For loop automation syntax |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○Create script "backup_logs.sh"
- ○Implement a for loop with cp
- ○Run the backup_logs.sh script
- ○Directory "backup/" holds copies
Ready to complete Quest 101?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.