What Are Your Favorite Command Line Hidden Gems?

twitter logo github logo ・1 min read

I just found out about gpp, which is a neat text preprocessor for quick and low-power templating. Which sparked me to look for other commands that are super cool but might not show up in the beginner tutorials.

So here it is: what are your favorite commands that might not be as popular? Bonus points if they come pre-packaged on your favorite OS. Big bonus if you don’t have to install them with a language-specific package manager like pop, gem, or npm—not because there’s anything wrong with u them. I’m just trying to steer this away from a pile of “just npm install kitchen-sink-robot-suit!”

twitter logo DISCUSS (10)
markdown guide
 

I am on Linux since 2005 and here's one of the most often used things:
I do CTRL + R to get the reverse CLI history, then I just type the first characters from: find . -type f -name ".*.sw*" -exec rm -f {} \;, find it then hit Enter.
It finds all the .swp, swo, etc files left from my vim sessions and deletes them.
Also, big lol @ npm install kitchen-sink-robot-suit :-))
That name surely needs a package!

 
 

My favorite command I often forget about is tee - used for simultaneously writing to the terminal AND to a file. It works best as part of a pipeline, which makes it a good fit for any shell supporting them - pretty much all the modern shells do now. I like to use this for verification: Did what my shell script print out match what I expect it to?

 

It's not so much of a command but rather the concept of the | symbol. The pipe symbol is pretty a universal concept.

I use it in Powershell commands and Linux commands.
This Linux command gets a lot of use:
ps -ef | grep <'any string here'>
Or
history | grep <'whatever command I think I just ran'>

 

curl -vvv is helpful for learning and experimenting with all things http related.

Not exactly a command, but favorite bad habit is running processes in the background with slow_cmd &.

 

The more I learn about curl, the more it blows my mind how powerful it really is.

With regards to backgrounding commands, I know about the ability, but I've never had an instance where I've thought to do it. What kind of commands do you find yourself backgrounding?

 

Mostly I background update commands when I first login. Definitely not a good habit but I always read the stdout.

flatpak update $
yay &
brew update &

 

One of my favorites is an oldie but goodie, the table_print gem.

It allows you to print arrays of data out in nice tables

 

file command to know file format. Some times file name may contains wrong extension or doesn't contain extension. In this case file command really helps to know the format of the file. Below is the syntax.

file file_name

And below are some of results for file command.

"ASCII text" - normal text file
"ASCII text, with very long lines" - CSV file with large lines
"Zip archive data, at least v4.5 to extract" - ZIP file

Classic DEV Post from Jun 1 '18

Awk - A useful little language

Speed up text processing tasks with this utility

Ryan Palo profile image
Ryan is a mechanical engineer in the East SF Bay Area with a focus on dynamic languages like Ruby & Python. Goal: learn a ton and become a physics, math, and programming teacher. Message me on DEV.TO

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️