Shell Chore
You'll pick one thing you do by hand every week and write a ten line script that does it for you.
About
The first script isn't really about the language. It's about noticing a chore and deciding not to do it by hand again. Sorting a downloads folder, pulling today's screenshots into one place or zipping up a project all make good first chores. Bash, PowerShell or Python all work, so use whatever already runs on your machine. The whole thing is about ten lines, and the point is that it ran and you didn't have to.
At a glance
- Per requirement
- 15 XP
- Completion bonus
- 75 XP
- Requirements
- 5
- Takes
- One week
- Skill level
- Beginner (done it a few times)
- Cost
- Free
- Supplies
- Nothing special
- Where
- At home
- Other people
- On your own
Requirements
-
1
Write down the chore and the exact steps you do by hand. Open a text file and list every click and command in the order you do them. Most chores turn out to be five steps you've never really looked at. If you can't write the steps down, you can't script them yet, so this list is the real start. Take a photo or screenshot of the list. Photo
-
2
Write a script that does those steps in ten lines or fewer. Use Bash on Mac and Linux, PowerShell on Windows, or Python anywhere. Start with the shebang line and one command, run it, then add the next line. Don't write the whole thing before you've run any of it, because the first line that fails is much easier to find on its own. Take a screenshot of the finished script. Photo
-
3
Make it executable and run it from any folder. Run chmod +x on the file, then move it somewhere on your PATH, or make a bin folder in your home directory and add that to your PATH. You'll know it worked when typing just the name from your home folder runs it. Take a screenshot of it running from a different directory than the one it lives in. Photo
-
4
Run it on a messy real folder rather than a test one. Copy the real folder first, so a mistake costs you nothing. Scripts that work on three test files tend to break on 300 real ones with spaces in their names, and the fix is almost always quoting your variables. Film the run so we see the folder before, the command, and the folder after. Video
-
5
Use it for a week, then write down what you changed. Most first scripts need two fixes by day three, and that's normal. Note each one as you make it. Take a screenshot of the script after a week, with a sentence on what changed and why. Photo