convert file storage size from one unit of measurement to another


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting convert file storage size from one unit of measurement to another
Prev   Next
# 1  
Old 03-15-2009
convert file storage size from one unit of measurement to another

The source number is always in megabytes and I need a script to covert into either MB,GB or TB displayed in a specific format.

Source number examples:

5345376635
34255
5453645846353

The result has to be maximum 2 numbers after the comma

1.13 TB
134.17 TB
413.46 GB
678.45 MB

I know a couple ways to calculate it but how to make it just 2 numbers after comma?

Code:
 EXAMPLE1="`expr $SOURCE / 1024 / 1024` TB"
 EXAMPLE2="$(($SOURCE/1024/1024)) TB"
 EXAMPLE3="`echo|awk '{print '$SOURCE' / 1024 / 1024}'` TB"

 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

2. Shell Programming and Scripting

Measurement file parsing

I have an application performance measurement file with one thousand lines. Each line has some text indicating type of measurement and the last field containing the measured value. Each of the file has a unique measurement. I am interested in only extracting about 100 of those measurements and put... (2 Replies)
Discussion started by: yoda9691
2 Replies

3. UNIX for Dummies Questions & Answers

Display storage type and storage size

Can anybody help me ont to get the command to check storage type and storage size in unix. Thank u in advanced!! (4 Replies)
Discussion started by: manisham
4 Replies

4. Shell Programming and Scripting

The scripts not able to make the file to size 0, every times it go back to its original size

#!/bin/sh ########################################################################################################## #This script is being used for AOK application for cleaning up the .out files and zip it under logs directory. # IBM # Created #For pdocap201/pdoca202 .out files for AOK #1.... (0 Replies)
Discussion started by: mridul10_crj
0 Replies

5. AIX

VIO SAN STORAGE LPAR ( Dynamically increasing size )

Hi, Is there a way to dynamically increase the size of virtual disk on the LPAR. The virtual disk is coming from my VIO Server. From my SAN I have allocated a disk to VIO Server and from VIO Server to my LPAR....If I increase the space of the logical SAN DISK (DS 4700 using IBM TotalStorage... (0 Replies)
Discussion started by: filosophizer
0 Replies

6. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies

7. Filesystems, Disks and Memory

AIX and DS4300 Storage Unit

Hello, We're setting up a solution for a group of customers with 2 p520 servers and 1 DS4300 unit with 9 disks (at this stage). The meaning is to create two arrays on the DS4300. Both servers will be connected to the DS4300 unit and to both controllers (e.g. Controller 1 connected to server 1... (0 Replies)
Discussion started by: EricBE
0 Replies

8. UNIX for Dummies Questions & Answers

Convert block size to mb

If I execute this command: $ ls -lt | awk '{print $5}' | sort -nr |head -1 it returns the following value 57441881 If I execute this command: $ ls -s | sort -nr | head -1 | cut -d" " -f1 it returns the same file but now in block size 112208 Is there... (1 Reply)
Discussion started by: mh53j_fe
1 Replies
Login or Register to Ask a Question
STRUCT 
CMBDATA(9) The ccw bus STRUCT CMBDATA(9) NAME
struct_cmbdata - channel measurement block data for user space SYNOPSIS
struct cmbdata { __u64 size; __u64 elapsed_time; __u64 ssch_rsch_count; __u64 sample_count; __u64 device_connect_time; __u64 function_pending_time; __u64 device_disconnect_time; __u64 control_unit_queuing_time; __u64 device_active_only_time; __u64 device_busy_time; __u64 initial_command_response_time; }; MEMBERS
size size of the stored data elapsed_time time since last sampling ssch_rsch_count number of ssch and rsch sample_count number of samples device_connect_time time of device connect function_pending_time time of function pending device_disconnect_time time of device disconnect control_unit_queuing_time time of control unit queuing device_active_only_time time of device active only device_busy_time time of device busy (ext. format) initial_command_response_time initial command response time (ext. format) DESCRIPTION
All values are stored as 64 bit for simplicity, especially in 32 bit emulation mode. All time values are normalized to nanoseconds. Currently, two formats are known, which differ by the size of this structure, i.e. the last two members are only set when the extended channel measurement facility (first shipped in z990 machines) is activated. Potentially, more fields could be added, which would result in a new ioctl number. AUTHOR
Cornelia Huck <cornelia.huck@de.ibm.com> Author. COPYRIGHT
Kernel Hackers Manual 2.6. July 2010 STRUCT CMBDATA(9)