Windows PowerShell (practice mode: nothing here touches your real computer)
Lesson 12: Write and read (echo and cat)
Level 2, Talk to Your Computer: PowerShell. Write into a file with >, add with >>, read with cat. The new word: redirect (>). It follows lesson 11, Build things (mkdir and ni). Next comes lesson 13, Speed tricks.
What the lesson explains
Write and read. Put words in a file, then read them back.
Send words into a file. Then cat shows what is inside. On the card: echo "Buy milk" > list.txt
One replaces, two add. Two arrows put a new line at the end. On the card: echo "Bread" >> list.txt
A note in the vault. It is in Documents\vault. Find it, read it, and do what it says.
What you do first
An echo. In the practice terminal, type echo hello at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: hello.
The files on the practice computer
This lesson works in one folder. At the start, Documents\my-project holds club\, games\, images\, my-games\, hello.py, notes.txt.
Along the way you type echo "Buy milk" > list.txt, type echo "Feed the fish" > fish.txt, type echo "Bread" >> list.txt, find a note, secret.txt, in Documents\vault and type echo pizza > answer.txt. Lesson 13 opens with the files just as you leave them.
What you practise
Try it, "An echo": In the practice terminal, type echo hello at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: hello.
Try it, "Write, then read": In the practice terminal, type echo "Feed the fish" > fish.txt at the prompt PS C:\Users\you\Documents\my-project>; the prompt then reads PS C:\Users\you\Documents\my-project>. Then: In the practice terminal, type cat fish.txt at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: Feed the fish.
Challenge, "Secret mission": Do what the secret note says. Starting at PS C:\Users\you\Documents\my-project>, one way takes 3 commands: cd ..\vault; cat secret.txt; echo pizza > answer.txt (par: 4).
What PlayBuddy and PlayType say
PlayType: "Empty files are boring. Let’s put words inside them!"
PlayBuddy: "The arrow sends the words into a file, not onto the screen."
PlayType: "Careful! One arrow replaces everything. Two arrows add a new line."
PlayType: "Psst! I hid a secret note in the vault. Can you find it?"
Help in every lesson
Everything happens on a pretend computer in your browser, so nothing touches your real files. PlayBuddy and PlayType stand beside the board, cheer you on and say when it is your turn.
A green ring shows where to click the first time. After that you do it on your own, and if you slip twice the ring comes back.
Stars
The lesson has 4 things to do. Up to one slip in ten gives three stars, up to one in four gives two, and finishing always gives at least one. Stars and progress are saved in this browser only; there is no account.
About DayOneCode
DayOneCode is an independent learning site, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.