This question came to my mind last day when I wanted to free up some space on my HDDs and when it comes to what to delete (feel the pain), I wanted to know without lot of right-clicks which folders are the fattiest. As a good Windows user, I installed Total Commander, because some random Google result told me to do so.
Then I realised, heck, I have an entire UNIX environment on my PC (MSYS2), so maybe there is an utterly simple one liner command for achieve this. And guess what, it has: :)
$ du -sh * | sort -h
Life hack, place this in your .bashrc file:
# Within the current directory, list all folders and files
# and print their size, then sort it from smallest to largest:
alias du='du -sh * | sort -h'
What are your UNIX pipeline commands, where you can combine some program's standard output and creating something wicked simple time saver?
Latest comments (42)
Not exactly pipes but some very useful aliases that sometimes save me a lot of keystrokes
zsh global aliases:
Also using zsh with:
1 - fasd cd
2 - zsh-autosuggestions
3 - zsh-autopar
But xargs combined with find like:
print0 and xargs -0 makes us avoid some erros comming from files with spaces on its names
I know it's about pipe commande but since I saw some other interesting elements without pipe in it, I want to share some of them that help me daily. Hope you don't mind.
I have multiple aliases in my
.aliasesbut some also in my.gitconfigmore specific to git.My favorite one is :
You can find more of them into my .dotfiles repo on github
Top client IP in apache logs.
Work also for any field : top URL, top browser etc. Damn fast !
This prints the top 10 most used commands in the history. I then created one-letter aliases for these (e.g.
alias s='git status'), saving numerous keystrokes.this will just highlight the word you are greping for but still print out the entire file.
I have some personal libraries that are easily installable in other hosts, by following the README:
github.com/stroparo/ds
I also have a personal setup script which installs my selection of APT (debian/ubuntu) and Yum (fedora/redhat) packages, plus Oh-My-Zsh, plus the Daily Shells ('ds') repo linked to above. Just follow the installation instructions for setup-dev.sh at the bottom of this README:
github.com/stroparo/cmds#setup-a-l...
Best,
Exploded with files + dirs:
du -ma | sort -rn | head # summary (10 items)
du -ma | sort -rn | less # scroll with the 'less' command
I've used this exact line a couple days ago!
I have a lot of data in JSON format, and gron has been a lifesaver. Combined with the usual suspects grep, sed, cut, awk, sort, etc.
Cool! This looks a lot simpler than jq (which I use regularly).
Examples: