Sum in terabyte


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sum in terabyte
# 1  
Old 04-03-2013
Sum in terabyte

Hello,
can someone help me in this
I have a file of sizes in kilobyte I want to caculte the sum in terabyte using awk

I would like to have one digit after the decimal point ( 2.8 TB for example)

Code:
 
cat file
2881301319
3061567196
3010347398
3029693706
2906516319
2444536488
1861082168
.
.

Thanks..Sara

Last edited by Corona688; 04-03-2013 at 12:34 PM..
# 2  
Old 04-03-2013
Code:
awk '{printf "%.1f TB\n",$1/1000000000}' file
2.9 TB
3.1 TB
3.0 TB
etc


Last edited by Jotne; 04-03-2013 at 08:58 AM..
# 3  
Old 04-03-2013
Code:
8 bits = 1 byte
1,024 bytes = 1 kilobyte
1,024 kilobytes = 1 megabyte
1,024 megabytes = 1 gigabyte
1,024 gigabytes = 1 terabyte
1,024 terabytes = 1 petabyte

so it would be num/(1024*1024*1024)

awk 'BEGIN {t=1024*1024*1024} {printf "%.1f TB\n" $0/t;}' file

Last edited by PikK45; 04-03-2013 at 08:32 AM.. Reason: missed a number :)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Multi-terabyte filesystem space increase on AIX7.1

Hi, I need to increase a filesystem from around 1TB to 15TB on a running AIX7.1 TSM server. This will be by far the largest single filesystem increase I've ever performed, or even heard of. The volume group already has enough disk available (in fact the filesystem was always intended to be... (10 Replies)
Discussion started by: alanp36
10 Replies

2. Shell Programming and Scripting

How to get the sum?

hi Gurus, I have an extract as seen below: INPUT 2015-08-24 15:00:00.0 |TCSERVER01 |ServiceEventHandler |2283 2015-08-24 15:01:00.0 |TCSERVER01 |ServiceEventHandler |576 2015-08-24 15:02:00.0 |TCSERVER01 |ServiceEventHandler |833 2015-08-24 15:03:00.0 |TCSERVER01 |ServiceEventHandler... (6 Replies)
Discussion started by: reignangel2003
6 Replies

3. UNIX for Dummies Questions & Answers

Sum with condition

Dear masters, I have file input 011171646073|12129|12129|A027|20141001|20141015|2014|10|01|2013|10|15 011171646076|12129|12129|A027|20141001|20141012|2014|10|01|2014|09|12 011171646078|12129|12129|A027|20141001|20141015|2014|10|01|2014|10|15... (6 Replies)
Discussion started by: radius
6 Replies

4. Shell Programming and Scripting

How to sum these value.

Hi, Unix Gurus, I need sum values from a file. file format like: 0004004 0000817 0045000 0045000 0045000 0045000 0045000 0045000 0045000 0045000 0045000 0045000 0004406 the result should be 459227 (817+45000 ... + 4406) anybody can help me out (7 Replies)
Discussion started by: ken002
7 Replies

5. UNIX for Dummies Questions & Answers

Getting the sum

I am trying to get the sum of the first column of a file. When I use the same method for other files it works just fine... for some reason for the file below it gives me an error that I don't understand... I tried looking at different lines of the file and tried different things, but I still... (7 Replies)
Discussion started by: cosmologist
7 Replies

6. Solaris

How to Sum

Hi I need to incorporate a 'sum' as follows into a script and not sure how. I have a variable per line and I need them to be summed, e.g below 1 23 1,456 1 1 34 46 How do I calculate the sum of all these numbers to ouptut the answer ( 1,562) Thanks in advance (3 Replies)
Discussion started by: rob171171
3 Replies

7. Shell Programming and Scripting

Print sum and relative value of the sum

Hi i data looks like this: student 1 Subject1 45 55 Subject2 44 55 Subject3 33 44 // student 2 Subject1 45 55 Subject2 44 55 Subject3 33 44 i would like to sum $2, $3 (marks) and divide each entry in $2 and $3 with their respective sums and print for each student as $4 and... (2 Replies)
Discussion started by: saint2006
2 Replies

8. Shell Programming and Scripting

Unique values from a Terabyte File

Hi, I have been dealing with a files only a few gigs until now and was able to get out by using the sort utility. But now, I have a terabyte file which I want to filter out unique values from. I have a server having 8 processor and 16GB RAM with a 5 TB hdd. Is it worthwhile trying to use... (6 Replies)
Discussion started by: Legend986
6 Replies

9. Shell Programming and Scripting

Calculate Gigabyte and Terabyte

Guy's I need help calculating a list of numbers that will be majority Terabytes but also have Gigabytes intermingled. So far when I calculate this, the Gigabytes throw off my true Terabyte total. Here is a list…… total 1.56 TB ,Mon Jun 09 23:59:11 2008 total 3.42 TB ,Tue Jun 10 23:59:10 2008... (3 Replies)
Discussion started by: terryporter51
3 Replies

10. Shell Programming and Scripting

sum

Hello everyone I need to write a script that sums numbers passed to it as arguments on the command line and displays the results. I must use a for loop and then rewrite it using a while loop. It would have to output something like 10+20+30=60 this is what I have so far fafountain@hfc:~$ vi sum... (1 Reply)
Discussion started by: Blinky85
1 Replies
Login or Register to Ask a Question