#!/bin/bash # randomized disk usage # spukspital@openmailbox.org # 2016-06-27 # read du, write to file du -sh /home/* 2> /dev/null | awk '{ print $1 }' > values # clear file to be shuffled later echo "" > shufme # define function to write pseudo pixels function pxl { # write all values to array arr arr=($(grep $u values)) for i in ${arr[@]} do # trim last char in each value v=${i%?} # careful in the following line, might mess with your locale! # "." or "," it may be, depending on where you live. # this will cause the result to be slightly inaccurate, but this script # is not meant to be accurate, anyway. r=${v%%.*} c=0 while [ $c -lt $r ]; do printf '<span class="p %s"> </span>' $u >> shufme let c=c+1 done printf "\n" >> shufme done } u=G pxl u=M pxl u=K pxl # generate html output echo '<!DOCTYPE html><html><head><title>radius</title><link rel="stylesheet" type="text/css" href="radius.css"></head><body><div class="cn">' > radius.html # write shuffled lines to html and remove empty lines shuf shufme | grep -v '^$' >> radius.html # write file end echo '</div></body></html>' >> radius.html