#!/bin/sh # Time-stamp: <dom 20-jan-2008 05:27:37 exal on bernardita> # Autor: Exal de Jesus Garcia Carrillo <exal AT softwarelivre DOT org> # Copyright (C) 2007,2008 Exal de Jesus Garcia Carrillo SCRIPTNAME=`echo "$0" | sed -e 's,.*/,,'` OPTION=$1 NUMBER=$2 if [ -z $1 ] || [ -z $2 ]; then echo -e "usage: $SCRIPTNAME <OPTION> <NUMBER TO CONVERT>" cat <<EOF This script is for convert units, the options are: -b for bytes -k for kilobytes -m for megabytes -g for gigabytes EOF exit 0 fi case $1 in -b) echo -e "$2 Bytes are equal to:\n" echo "$2/1024*100000/100000" | bc | xargs echo "Kilobytes" echo "$2/1048576*100000/100000" | bc | xargs echo "Megabytes" echo "$2/1073741824*100000/100000" | bc | xargs echo "Gigabytes" exit 0 ;; -k) echo -e "$2 Kilobytes are equal to:\n" echo "$2*1024*100000/100000" | bc | xargs echo "Bytes" echo "$2/1024*100000/100000" | bc | xargs echo "Megabytes" echo "$2/1048576*100000/100000" | bc |xargs echo "Gigabytes" exit 0 ;; -m) echo -e "$2 Megabytes are equal to:\n" echo "$2*1048576*100000/100000" | bc | xargs echo "Byte" echo "$2*1024*100000/100000" | bc | xargs echo "Kilobyte" echo "$2/1024*100000/100000" | bc | xargs echo "Gigabyte" ;; -g) echo -e "$2 Gigabytes are equal to:\n" echo "$2*1073741824*100000/100000" | bc | xargs echo "Bytes" echo "$2*1048576*100000/100000" | bc | xargs echo "Kilobytes" echo "$2*1024*100000/100000" | bc |xargs echo "Megabytes" exit 0 ;; *) echo -e "Invalid option, try \`\`$SCRIPTNAME -h'' for help usage." ;; esac
|
[ EN ] [ ES ] [PT]
Copyright (C) 2006,2007,2008 Exal de Jesus Garcia Carrillo |
Last update: fevereiro 5, 2008 |
