awk Convert bytes to KB, MB or GB

Use the following to convert bytes to KB, MB or GB

echo "11714246384" | awk '{ byte = $1 /1024 ; print byte " k";byte = $1 /1024/1024 ; print byte " MB"; byte =$1 /1024/1024**2 ; print byte " GB" }'

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.