Size calculation MB to GB | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Size calculation MB to GB

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-09-2013
Daniel Gate Daniel Gate is offline
Registered User
 
Join Date: May 2008
Last Activity: 30 September 2014, 7:24 AM EDT
Posts: 215
Thanks: 78
Thanked 0 Times in 0 Posts
Size calculation MB to GB

PHP Code:
pcmpath query device |awk 'BEGIN{print "TYPE\tDEVICE NAME\tSERIAL\tSIZE\tHOSTNAME"}
 /DEVICE/ {
            disk=$5
            printf "%s\t", $7
            printf "%s\t", disk
            getline; printf "%s\t", substr($2, length($2)-3)
            ("bootinfo -s " disk) | getline; printf "%s\t",$0; sum+=$0
            printf "%s\n", hostname
 }      END {print "TOTAL SIZE:", sum}' 
hostname=`uname -n
I have this query working, but it returns SIZE in MB. I want the SIZE output in GB. I tried
HTML Code:
("bootinfo -s " disk)/1024
, but not working.

Please advise.
Sponsored Links
    #2  
Old 02-09-2013
Jotne's Avatar
Jotne Jotne is offline
Registered User
 
Join Date: Dec 2010
Last Activity: 20 September 2014, 2:08 AM EDT
Posts: 1,040
Thanks: 62
Thanked 216 Times in 204 Posts
Divide at the print function
eks

Code:
("bootinfo -s " disk) | getline; printf "%s\t",$0/1024; sum+=$0/1024

The Following User Says Thank You to Jotne For This Useful Post:
Daniel Gate (02-09-2013)
Sponsored Links
    #3  
Old 02-09-2013
Daniel Gate Daniel Gate is offline
Registered User
 
Join Date: May 2008
Last Activity: 30 September 2014, 7:24 AM EDT
Posts: 215
Thanks: 78
Thanked 0 Times in 0 Posts
Thank you! it works perfect!
    #4  
Old 02-09-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 30 September 2014, 10:26 AM EDT
Location: Aachen, Germany
Posts: 4,292
Thanks: 73
Thanked 1,035 Times in 980 Posts
Or
Code:
("bootinfo -s " disk) | getline; $0/=1024; printf "%s\t",$0; sum+=$0

The Following User Says Thank You to RudiC For This Useful Post:
Daniel Gate (02-11-2013)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to read file size and send email only if size > 0. welldone Shell Programming and Scripting 5 04-29-2011 10:03 AM
The scripts not able to make the file to size 0, every times it go back to its original size mridul10_crj Shell Programming and Scripting 0 10-03-2010 05:55 AM
File Size calculation with AWK EAGL€ Shell Programming and Scripting 1 09-04-2009 11:04 AM
Partitioning script for rescue mode (disk size calculation) pug123 Shell Programming and Scripting 1 07-29-2008 02:05 PM
command to find out total size of a specific file size (spread over the server) abhinov Solaris 3 08-08-2007 06:48 AM



All times are GMT -4. The time now is 01:52 PM.