Day 6: Down the Linux Rabbit Hole

I continued my work on exercise 4 from the MIT Missing Semester course Lecture 2 but that was just how the day started. The course recommended using a GNU/Linux based operating system or a virtual machine to complete the course work. So far in the course I have been able to work around that requirement just by using Git Bash which I had already installed on my Windows computer. Unfortunately, I have now met it’s limitation because git bash doesn’t come with the zip program installed by default. And this is how my trip down the rabbit hole began.

TLDR;

Okay, so here are the highlights of what I did:

  • Continued working on my solution for exercise 4 from MIT Missing Semester Course. I took notes on the -exec action option for the find program.
  • Looked into how to install a Linux subsystem on a Windows 10 PC.
  • Started looking at the manual pages for the zip program so that I can use it to complete exercise 4.

Exercise 4

Here is the problem from the lecture:

As we covered in the lecture find’s -exec can be very powerful for performing operations over the files we are searching for. However, what if we want to do something with all the files, like creating a zip file? As you have seen so far commands will take input from both arguments and STDIN. When piping commands, we are connecting STDOUT to STDIN, but some commands like tar take inputs from arguments. To bridge this disconnect there’s the xargs command which will execute a command using STDIN as arguments. For example ls | xargs rm will delete the files in the current directory.

Your task is to write a command that recursively finds all HTML files in the folder and makes a zip with them. Note that your command should work even if the files have spaces (hint: check -d flag for xargs).

If you’re on macOS, note that the default BSD find is different from the one included in GNU coreutils. You can use -print0 on find and the -0 flag on xargs. As a macOS user, you should be aware that command-line utilities shipped with macOS may differ from the GNU counterparts; you can install the GNU versions if you like by using brew.

My Current Progress

$ find . -path *.html -type f

Over the past two days my understanding of the find program has grown. However, I also need to know how to use the zip program to collect all the .html files from find to produce one .zip file that contains all of them.

The temptation for me here is what do I want to do about my tools for the course. I have 3 options right now:

  1. I looked up how to add zip to git bash and it seems reasonable.
  2. I also looked into adding Linux as a subsystem which is tempting.
  3. Spin up the Ubuntu Virtual Machine instance that’s been sitting on my computer instead of doing all this extra stuff lol (But that would be boring).

I am still weighing the balance of the three but I guess the most logice solution would be #3. Regardless looking through these options were a huge distraction and caused me not to finish the exercise. I need to get more focused if I want to finish this course before the end of August!!

Conclusion

That’s all for today. Btw if you are interested in the MIT course you can check out the video lecture I’m currently doing the exercises for. The lecture is helpful but isn’t sufficient by itself. Anyways, until next time PEACE!

YouTube player