Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


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

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-09-2013
Registered User
 
Join Date: May 2008
Posts: 170
Thanks: 68
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
Registered User
 
Join Date: Dec 2010
Posts: 522
Thanks: 45
Thanked 98 Times in 91 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
Registered User
 
Join Date: May 2008
Posts: 170
Thanks: 68
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
Location: Aachen, Germany
Posts: 1,881
Thanks: 25
Thanked 434 Times in 420 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
Reply

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 04:51 PM.