DEV Community

Daniel Brady
Daniel Brady

Posted on

What's your current favorite shell command?

Top comments (10)

Collapse
 
daniel13rady profile image
Daniel Brady • Edited

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
$ 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

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

Collapse
 
dingdingdong profile image
The D

sl

Collapse
 
daniel13rady profile image
Daniel Brady

👏 I didn't tell the whole truth above: I currently have ls aliased to clear; tree.

Collapse
 
ahmedibrahimq profile image
Ahmed Ibrahim

du -h --max-depth=1

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