Lab: The Messy Repo
Due: Wednesday, October 21 at 11:59pm (one week after it is assigned) · Worth: 8 points
The shell lets us find, move, and count files. You’ll use it to organize a messy folder, then save the cleanup commands in a script you can run on another copy.
Start
Download and extract the starter ZIP. Open the inner lab-shell folder in VS Code, then initialize and publish your repository as lab-shell. Use a Bash terminal. On Windows, select Git Bash in VS Code. From the repository root, generate the practice files:
mkdir -p messy-repo
cd messy-repo
bash ../make_mess.shKeep the supplied answer and script outlines in messy-repo. Do not initialize another Git repository inside it.
Clean up the repository
Inspect the files with pwd, ls, and cat. Find the flag before changing the folder, then write and run the cleanup script. Record the three counts after cleanup. The shell reading covers navigation, wildcards, searching, and pipes.
Find and count
Use the shell to inspect the generated folder and fill in messy-repo/answers.txt. Keep the provided labels: adding the literal search strings to that file would change later search results. Use > and >> to write your answers. See searching and pipes.
-
Find the file containing
FLAG{...}and record its path and line number. -
Record the total number of lines in the top-level Python files after cleanup.
-
Record the number of lines containing
TODOanywhere in the cleaned tree. -
Record the number of Python files at the top level after cleanup.
Write the cleanup script
Put the cleanup commands in messy-repo/tidy.sh. Preview wildcard matches with ls before using mv or rm. Run the script before recording the three counts. It must work on a fresh copy of the mess, but does not need to work twice on the same folder.
-
Create a
homework/directory. -
Move all four homework files into it with one
mvcommand, preserving their contents. -
Remove the top-level
.tmpand.logfiles. -
Leave every other supplied file in place with its contents unchanged.
Check and submit
To test the script again, create a separate folder outside messy-repo. Run make_mess.sh in that folder, then run bash with the path to your tidy.sh. Check that the four homework files moved, the temporary and log files disappeared, and the other files are still there.
Return to the cleaned messy-repo and check the answers. Keep extra test copies outside it so recursive searches do not count them.
Commit and sync messy-repo/answers.txt and messy-repo/tidy.sh. On Gradescope, choose GitHub and submit lab-shell and the branch containing your work. The submission guide explains resubmission.