Great writeup, Malik - thanks for sharing! Since you asked for some tips, let me share two of my favorites:
First is !$ - it's similar to !!, but instead of expanding to the entire previous command, it just expands to the final argument of the previous command. It's really useful for chaining commands that operate on the same file; here's one example that I find myself using a lot:
$ mkdir foo
$ cd !$
The second is the noclobber shell option, which is present in both bash and zsh. You mentioned above that > will destroy a file if you redirect to a file that already exists - set -o noclobber prevents that! I can't tell you how many times this has prevented me from destroying work!
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
Great writeup, Malik - thanks for sharing! Since you asked for some tips, let me share two of my favorites:
First is
!$
- it's similar to!!
, but instead of expanding to the entire previous command, it just expands to the final argument of the previous command. It's really useful for chaining commands that operate on the same file; here's one example that I find myself using a lot:The second is the
noclobber
shell option, which is present in both bash and zsh. You mentioned above that>
will destroy a file if you redirect to a file that already exists -set -o noclobber
prevents that! I can't tell you how many times this has prevented me from destroying work!I use
noclobber
everywhere and then use>|
if I know I want to overwrite something, because we've all done that...Oooh! Definitely adding these to the list. Thank you for sharing itβs part of the reason I wanted to write this post π