you can try removing the "$" when setting your variables and replace the
parentheses with command ticks:
#!/usr/bin/sh
value=$1
kilo=`echo "scale=2; $value / 1024" | bc`
kiloint=`echo "$value / 1024" | bc`
mega=`echo "scale=2; $kilo / 1024" | bc`
megaint=`echo "$kilo / 1024" | bc`
giga=`echo "scale=2; $mega / 1024" | bc`
gigaint=`echo "$mega / 1024" | bc`
if [ $kiloint -lt 1 ] ; then
echo "${value} KB"
elif [ $megaint -lt 1 ] ; then
echo "${kilo} MB"
elif [ $gigaint -lt 1 ] ; then
echo "${mega} GB"
else
echo "${giga} TB"
fi
good luck and hope this helps.
On Thu, Jun 10, 2010 at 2:49 PM, Paul Ward <[email protected]> wrote:
> Hi guys,
>
> Is there someone who can edit my shell script so it works on Solaris 8,9 &
> 10.
>
> It runs fine on Linux but I have not figured out how to get it to run
> on Solaris.
>
> Many thanks
>
> SCRIPT BEGIN --->
>
> #!/usr/bin/sh
>
> value=$1
> kilo=$( echo "scale=2; $value / 1024" | bc )
> kiloint=$( echo "$value / 1024" | bc )
>
> mega=$( echo "scale=2; $kilo / 1024" | bc )
> megaint=$( echo "$kilo / 1024" | bc )
>
> giga=$( echo "scale=2; $mega / 1024" | bc )
> gigaint=$( echo "$mega / 1024" | bc )
>
> if [ $kiloint -lt 1 ] ; then
> echo "${value} KB"
> elif [ $megaint -lt 1 ] ; then
> echo "${kilo} MB"
> elif [ $gigaint -lt 1 ] ; then
> echo "${mega} GB"
> else
> echo "${giga} TB"
> fi
>
>
> <---- SCRIPT END
>
> To run use:
> ./convert.sh <SIZE>
> _______________________________________________
> Solaris-Users mailing list
> [email protected]
> http://www.filibeto.org/mailman/listinfo/solaris-users
>
_______________________________________________
Solaris-Users mailing list
[email protected]
http://www.filibeto.org/mailman/listinfo/solaris-users