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
.aliases
but some also in my.gitconfig
more 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:
I often use this one get the pid of the parents of zombie process.
Apart from that I often use
grep
,sort -u
,sed
.A funny one is to pipe
fortune
withcowsay
Some dumb and possibly dangerous variations I use:
I have used perl in pipes a lot for when you need to change something easily using a regular expression.
$ find . -name "*Relevant*.pm" | xargs perl -pi -e 's/something/somethingelse/'
The find name part can be tweaked to suit your needs and the regular expression in the Perl part also.
On a mac:
‘pbpaste | sort | pbcopy’
To sort (or otherwise process) what’s in the clipboard.
This is a link to my bash_profile where I added a bunch of functions and aliases that helped me save a lot of time github.com/robertodessi/custom_con...