DEV Community

Discussion on: Helpful Terminal Commands for Beginners!

Collapse
 
hoelzro profile image
Rob Hoelz

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!

Collapse
 
moopet profile image
Ben Sinclair

I use noclobber everywhere and then use >| if I know I want to overwrite something, because we've all done that...

Collapse
 
milkstarz profile image
malik

Oooh! Definitely adding these to the list. Thank you for sharing it’s part of the reason I wanted to write this post πŸ˜„