DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 970,177 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Daniel Brady
Daniel Brady

Posted on

What's your current favorite shell command?

Top comments (13)

Collapse
 
kristories profile image
Wahyu Kristianto • Edited on
$ clear

Like a blackhole. You will have a dark room.

Collapse
 
kristories profile image
Wahyu Kristianto

I will not use the CTRL + L shortcut. Just press the ^ arrow and look for the clear command that I have used before. How lazy I am ~

Collapse
 
daniel13rady profile image
Daniel Brady Author

πŸ‘ I didn't tell the whole truth above: I currently have ls aliased to clear; tree.

Collapse
 
aminnairi profile image
Amin

You can even use CTRL + L as a shortcut for clear in most of the terminal emulators!

Collapse
 
alinp25 profile image
Alin Pisica

I would rather CTRL+L

Collapse
 
daniel13rady profile image
Daniel Brady Author • Edited on

tree --dirsfirst -phFDC -L 3

Example output of `tree --dirsfirst -phFDC -L 3`

I love tree. I currently have this aliased to ls.

Collapse
 
aminnairi profile image
Amin • Edited on
$ for file in folder/**/*.pdf; do echo $file; done

This one is my favorite because it allows for a recursive for loop in ZSH. You could use find to do the job, but you can have variables and write visually better code with this for loop.

Note that it might not work in Bash.

I would be happy to learn an even better way of doing it though!

Collapse
 
delimanicolas profile image
Nicolas Lima

split -l 7000 my_giant_json.json sub_files.json . It is far from being the command I use most, but recently it saved me during a data migration process. You can use it to split a file into several smaller chunks and then operate them.

It works like this: split -l (form number of lines) -b (for bytes) my_giant_json.json sub_files.json

Collapse
 
deciduously profile image
Ben Lovy

history | grep

I'm lazy and forgetful, what can I say.

Collapse
 
daniel13rady profile image
Daniel Brady Author

I do this a lot for arcane commands I executed once 2 years ago to fix that one thing that popped up again.

Collapse
 
ahmedibrahimq profile image
Ahmed Ibrahim

du -h --max-depth=1

Collapse
 
dingdingdong profile image
The D

sl

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.