seed: curriculum content

This commit is contained in:
2026-05-07 14:32:44 +00:00
parent 9258534803
commit ec76f4f56b
100 changed files with 2846 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
---
type: challenge
title: "The Searcher"
xp: 75
duration: 30
difficulty: 3
---
# The Searcher
> **[INCOMING — Mission Control, Earth]**
>
> Cadet, an archive arrived. Somewhere in it, a single log file
> mentions the word `BREACH`. We need it found.
>
> Two commands:
>
> - `find <path> -name "<pattern>"` — locate files by name
> - `grep -rl "<text>" <path>` — search file contents recursively,
> list only the matching file paths
>
> Your script must produce two files:
>
> 1. `logs.txt` — every `.log` file under `archive/`
> 2. `breach.txt` — the path to the file containing `BREACH`
>
> [END TRANSMISSION]
## Your Task
In `starter/starter.sh`, write the two commands.
## Objectives
- `logs.txt` lists every `.log` file under `archive/`
- `breach.txt` contains the path to the file mentioning `BREACH`

View File

@@ -0,0 +1,13 @@
#!/bin/bash
# The Searcher — find things in an archive.
#
# When this script runs, an `archive/` directory tree exists with
# many files. Somewhere in it, a single .log file mentions BREACH.
#
# Your script must produce two files:
# - logs.txt — every `.log` file path under archive/, one per line
# - breach.txt — the path to the file containing the word BREACH
#
# Tools: find, grep -rl
# Your code here.

View File

@@ -0,0 +1,22 @@
#!/bin/bash
mkdir -p archive/sectors/a archive/sectors/b archive/sectors/c archive/data archive/old
echo "[03:30] Sector A nominal." > archive/sectors/a/sector-a.log
echo "[03:32] Sector B nominal." > archive/sectors/b/sector-b.log
printf '[03:30] Sector C nominal.\n[03:42] BREACH detected at perimeter.\n' > archive/sectors/c/sector-c.log
echo "[00:00] Logger online." > archive/data/raw.log
echo "Notes" > archive/data/notes.txt
echo "[01:00] Legacy." > archive/old/old.log
bash solution.sh > /dev/null 2>&1
N=0
report() { N=$((N+1)); if [ "$1" = "0" ]; then echo "ok $N - $2"; else echo "not ok $N - $2"; fi; }
[ -f logs.txt ]; report $? "logs.txt exists"
EXPECTED=$(find archive -name "*.log" | sort)
ACTUAL=$(sort logs.txt 2>/dev/null)
[ "$EXPECTED" = "$ACTUAL" ]; report $? "logs.txt lists all .log files"
[ -f breach.txt ]; report $? "breach.txt exists"
grep -q "sector-c.log" breach.txt 2>/dev/null; report $? "breach.txt references sector-c.log"