here is the quick script for handy use
#!/bin/bash# Give numeric value, which is in bytes# will show all possible conversionscall_bc() {n1=$1n2=$2echo "scale=4; $n1/($n2)" |bc}nm=$1pw=$2pn=""k_ilo=1024;m_ega=$k_ilo*$k_ilo;g_iga=$m_ega*$k_ilo;t_era=$g_iga*$k_ilo;p_eta=$t_era*$k_ilo;[ -z "$nm" ] && exitecho "B: "$nmfor i in K M G T P; docase $i inK)pn=$k_ilo;;M) let pn=$m_ega;;G) let pn=$g_iga;;T) let pn=$t_era;;P) let pn=$p_eta;;esacecho -n "$i: "; call_bc $nm $pndone
Usage and output
$ ./convert.sh 74274576B: 74274576K: 72533.7656M: 70.8337G: .0691T: 0P: 0
No comments:
Post a Comment