Skip to main content

Thread: Elegant Bash / SH script to convert human <-> bytes values?


hello,

sh/dash, have elegant script can handle such things?

or under awk, portability. http://www.softpanorama.org/tools/awk.shtml awk underappreciated coding , portable , universal

code:
54.4m = 57042534 bytes


welcome,

enjoy !!

echo "83498543893452" | awk '{ sum=$1 ; hum[1024**3]="gb";hum[1024**2]="mb";hum[1024]="kb"; (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x];break } }}'


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support New to Ubuntu [SOLVED] Elegant Bash / SH script to convert human <-> bytes values?


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support