Mastering native tools in UNIX
This post is more of a reminder than anything instructional, and it stemmed
from an experience I had this weekend migrating a daycare center’s website and
its products entire infrastructure to the cloud. As it turned out, I was stuck
on a gcloud shell
with nothing but the bare tools in that box, and it
solidified for me the title of this post. A lot my professional colleagues
always inquire into why I use a minimal vimrc
even though I also have a
“full-blown” vimrc
as well, or me not using great tools like ripgrep
and
fzf
for text manipulation, or the way I set up my networking with plain ‘ol
systemd
service files, etc.
And everything that I was subjecting myself to on a daily basis with my workflow paid tremendously this weekend. Let me give you a quick example:
I tend to use cat
, echo
and HEREDOCS
for quick configuration one-liners
to avoid opening a vim session or just to stay on the actual shell. During one
of these cat
editing sessions, I wrote a for
loop that made too many extra
changes across the filesystem. Which meant that major sed
replacements would
be required to make the changes persist. Now normally, tools like ripgrep
and
fzf
are great due to its speed and ease of use, and that would be what most
people recommend. However, under a slow connection, a gshell cloud
, speed of
execution, a native solution is required. The solution: Vim!
I spun up a vim session on the etc
directory, and ran a quick:
:args `find . -type f` #this build the arglist and sets up Ex's special var: ##
:argdo g/^\[\]/s/\[Units\]/\[Unit\]/gc ## | update
and voila! I was able to make those changes with confirmation in the process.
Conclusion
I cannot stress enough how important it is to be extremely comfortable with the
native tools in a *nix-based OS. My choice is Vim if i had to pick just one
to take with, since it includes so much out of the box, and I like the visual
aspect of everything it offers. Therefore, my decision to really really grok
Vim/Vi and all of its native features always pulls me out of pinch since it has
its own grep
, poor man's xargs
, build system through make
, gdb
integration support and of course, the most important piece: shell
integration