41.37% ############################################################## Others 17.96% ########################### Woody Allen 13.19% #################### Argentina 10.86% ################ Ingmar Bergman 6.55% ########## Serbia 3.92% ###### NI 2.24% ### Luis Bu?uel 0.95% # Jean Renoir 0.66% # M?xico 0.64% # Colombia 0.45% # Charlie Chaplin 0.45% # Leni Riefenstahl 0.42% # Cuba 0.36% # Chile
i'm using gawk, you may get varying mileage with other varieties. You might want to change the / after du to say, /home/ or /var or something, otherwise this command might take quite some time to complete. Sorry it's so obsfucated, I had to turn a script into a one-liner under 255 characters for commandlinefu. Note: the bar ratio is relative, so the highest ratio of the total disk, "anchors" the rest of the graph. EDIT: the math was slightly wrong, fixed it. Also, made it compliant with older versions of df. Show Sample Output
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
... | awk -F / -v c=$COLUMNS 'NR==1{t=$1}NR>1{r=c*$1/t+0.5;printf " %5.2f%% \033[1;7;31m%*s\033[0m %s\n",100*$1/t,r,"",$2}' | ...
. I've also dropped the int() which wasn't needed, at least for Gnu awk. .du -x --max-depth=1|sort -rn|awk -F / -v c=$COLUMNS 'NR==1{t=$1}NR>1{r=c*$1/t+0.5;printf " %5.2f%% \033[1;7;31m%*s\033[0m %s\n",100*$1/t,r,"",$2}'|tac
COLUMNS=${COLUMNS-$(tput cols)}