cat prints a whole file and grep prints only the lines that contain a word. Names that start with a dot are hidden: ls skips them, ls -a shows them. With these you can find anything on a computer you can't see.
ls shows four things in Sam's home folder. There are five. Where's the other one?
In Where files live you moved around and looked. Now read what's inside files, and find the ones that don't want to be seen.
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Practise: A few on your own, to check you have it.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
What ls shows
TryTry it on the board and compare the result with your prediction.
Try: find the hidden file
Was your prediction right?
Try it yourselfYour edits are saved in this browser.
Find the hidden file in your home folder and print it with cat.
Use the board. This ticks when you get there.
InvestigateWork out why it happens, one step at a time.
Worked example: grep
Worked exampleBefore each step, say what you think comes next.
cat⇒printedThe line contains c-a-t.
dog⇒skippedNo c-a-t.
catfish⇒printedc-a-t is inside it: grep matches letters anywhere.
parrot, hamster⇒skippedNo c-a-t.
cat⇒printedThree lines in all.
Now count the lines.
pets.txt has six lines: cat, dog, catfish, parrot, cat, hamster. How many lines does grep cat pets.txt print?
Sam looks for a clue in the gym folder. Click the line where it first goes wrong.
ModifyChange the problem on purpose and see what happens.
Vary: find it fast
Try it yourselfYour edits are saved in this browser.
Print only the line of notes.txt that mentions Friday.
Use the board. This ticks when you get there.
How many pets have the letter a in them? Make grep count them with -c.
Use the board. This ticks when you get there.
Print level1.txt from your home folder, without using cd.
Use the board. This ticks when you get there.
PractiseA few on your own, to check you have it.
Reading
MakeMake your own problem using what you have learned. Expect a few tries; that is normal.
The treasure hunt, part 1
Then: on a real computer, what kinds of files do you think are hidden, and why?
Try it yourselfYour edits are saved in this browser.
Need a hint?
Start with cat start.txt.
Another hint
Each clue names a folder. Look inside with ls; read with cat.
Another hint
The gym clue is hidden: ls -a.
A treasure hunt starts in this folder. Follow the clues until you find the one hidden in the gym, and print it.
Use the board. This ticks when you get there.
For teachers
Students print files with cat, find lines with grep (including -i, -c and paths to other folders), reveal hidden names with ls -a, and follow a clue trail to a hidden folder (AC9TDI10K01 node 1). About 40 minutes.
Try the boards yourself, including the treasure hunt (fs: hunt): start.txt → library/shelf2/book.txt → gym/.locker/clue.txt. The hunt finishes in Pipes.
The one idea: you can read and search files you can't see, and "hidden" only means ls skips the name.
Running the lesson
Predict: students who said "everything" will meet .plans.txt in the Try.
Worked example: ask why catfish was printed.
Vary: ask why the third task didn't need cd.
Make: ask what made them try ls -a in the gym.
The hard part (on purpose)
grep matching inside words (catfish) surprises students; let the count come out wrong once, then look at the lines.
When students get stuck
A student says there's nothing more in the gym (Sam's mistake). Ask: What did ls -a show in your home folder that ls didn't? Fix: Try ls -a in the gym too.
grep finds nothing. Ask: Do the capitals match? Fix: grep is case sensitive; grep -i ignores capitals.
Stretch and support
Stretch: grep -n shows line numbers and grep -v shows the lines that don't match. When would each be useful?
Support: Add to the card: cat file (print it), grep word file (lines with word), ls -a (hidden too).
Where it leads
Next: Changing files.
What each step is for
what ls shows: Committing to whether ls shows everything tests the new move: hidden names need ls -a.
Try: find the hidden file: Finding and printing the hidden file settles the prediction and introduces cat.
Worked example: grep: Working out which lines grep prints models the new move: grep matches the word anywhere in a line. Sam trusts plain ls, the misconception planted after the method.
Vary: find it fast: Each task changes one thing: one matching line, counting with grep -c, then reading a file in another folder without moving.
reading: Choosing the right reading command is the same move in mixed forms, plus a review of paths.
the treasure hunt, part 1: Following clue files through folders, one of them hidden, puts the moves together: look, move, read, and look again with -a.