Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Size calculation MB to GB

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-09-2013
Daniel Gate Daniel Gate is offline
Registered User
 
Join Date: May 2008
Last Activity: 11 February 2015, 8:07 AM EST
Posts: 225
Thanks: 84
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 Unix and Linux 02-09-2013
Jotne's Unix or Linux Image
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 Unix and Linux 02-09-2013
Daniel Gate Daniel Gate is offline
Registered User
 
Join Date: May 2008
Last Activity: 11 February 2015, 8:07 AM EST
Posts: 225
Thanks: 84
Thanked 0 Times in 0 Posts
Thank you! it works perfect!
    #4  
Old Unix and Linux 02-09-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 22 May 2015, 5:26 AM EDT
Location: Aachen, Germany
Posts: 5,945
Thanks: 105
Thanked 1,588 Times in 1,492 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 10:43 PM.