seed: curriculum content
This commit is contained in:
35
1.solar-system/1.welcome/02.hello-world/index.md
Normal file
35
1.solar-system/1.welcome/02.hello-world/index.md
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "Hello, World"
|
||||
xp: 25
|
||||
duration: 15
|
||||
difficulty: 1
|
||||
---
|
||||
|
||||
# Hello, World
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, first signal. Write a script that creates `hello.txt`
|
||||
> containing exactly:
|
||||
>
|
||||
> ```
|
||||
> Hello, World
|
||||
> ```
|
||||
>
|
||||
> Two commands:
|
||||
>
|
||||
> - `echo` prints text
|
||||
> - `>` redirects what would print into a file
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
In `starter/starter.sh`, write the command(s) that create `hello.txt`
|
||||
with the content `Hello, World`.
|
||||
|
||||
## Objectives
|
||||
|
||||
- `hello.txt` exists in the working directory
|
||||
- File contents match `Hello, World` exactly
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
# Hello, World — your first script.
|
||||
# Write the line "Hello, World" into a file called hello.txt
|
||||
# in the current directory.
|
||||
|
||||
# Your code here.
|
||||
16
1.solar-system/1.welcome/02.hello-world/testing/test.sh
Normal file
16
1.solar-system/1.welcome/02.hello-world/testing/test.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
bash solution.sh > /dev/null 2>&1
|
||||
|
||||
if [ -f hello.txt ]; then
|
||||
echo "ok 1 - hello.txt is created"
|
||||
else
|
||||
echo "not ok 1 - hello.txt is created"
|
||||
fi
|
||||
|
||||
ACTUAL=$(cat hello.txt 2>/dev/null)
|
||||
ACTUAL="${ACTUAL%$'\n'}"
|
||||
if [ "$ACTUAL" = "Hello, World" ]; then
|
||||
echo "ok 2 - hello.txt contains 'Hello, World'"
|
||||
else
|
||||
echo "not ok 2 - hello.txt contains 'Hello, World'"
|
||||
fi
|
||||
Reference in New Issue
Block a user