I continued my work on the MIT Missing Semester course Lecture 2 exercises. This one was focused on writing find
commands that are useful. But let’s get into all the details below.
TLDR;
Okay, so here are the highlights of what I did:
- Started working on my solution for exercise 4 from MIT Missing Semester Course.
- Looked into the meaning of GNU and the FSF (Free Software Foundation).
- Started trying to write my own personalized notes for the
find
program in Bash since the manual was too detailed for a beginner like myself.
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 liketar
take inputs from arguments. To bridge this disconnect there’s thexargs
command which will execute a command using STDIN as arguments. For examplels | 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 forxargs
).
If you’re on macOS, note that the default BSD
find
is different from the one included in GNU coreutils. You can use-print0
onfind
and the-0
flag onxargs
. 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
I haven’t made much progress tbh. I have read a lot of the manual and tried to make sense and categorize all of the options that can be written when running the program.
I did however setup my folder to include two .html
files. One existing in the directory and another in a sub-directory. I figure that should work to prove my command’s effectiveness.
$ find . -path *.html -type f
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!